home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 35 Internet / 35-Internet.zip / isdnpm29.zip / pipe.cmd < prev    next >
OS/2 REXX Batch file  |  1996-10-04  |  4KB  |  123 lines

  1. /***************************************************************************
  2. ****************************************************************************/
  3. call RxFuncAdd 'SysSleep','RexxUtil','SysSleep'
  4. call RxFuncAdd 'SysLoadFuncs','RexxUtil','SysLoadFuncs'
  5. call SysLoadFuncs
  6. call RxFuncAdd 'FtpLoadFuncs','rxFtp','FtpLoadFuncs'
  7. call FtpLoadFuncs
  8.  
  9. /**************************************************************************/
  10. /*                                                                        */
  11. /*      there are some commands which v∩can be send to 'isdnPm' over      */
  12. /*      a named PIPE ("\PIPE\ISDNPM.CMD") .                               */
  13. /*                                                                        */
  14. /*                                                                        */
  15. /*                                                                        */
  16. /*       'FIRSTUSER' returns the first Userentry                          */
  17. /*       'NEXTUSER'  returns the following Userentries                    */
  18. /*                                                                        */
  19. /*       'CHANNELSTATUS <n>' returns the state of the channel <n>         */
  20. /*       'CHANNELSTATUS <u>' returns the state of the user    <u>         */
  21. /*                                                                        */
  22. /*       'CONNECT <u>' connects to the user <u>                           */
  23. /*       'DISCONNECT <u>' disconnects the user <u>                        */
  24. /*       'DISCONNECT <n>' disconnects the the channel <n>                 */
  25. /*                                                                        */
  26. /*       'CHANGEUSER <u> AUTODIAL ON'  turns the AUTODIAL on for <u>      */
  27. /*       'CHANGEUSER <u> AUTODIAL OFF' turns the AUTODIAL off for <u>     */
  28. /*                                                                        */
  29. /*                                                                        */
  30. /**************************************************************************/
  31.  
  32.  
  33. /**************************************************************************/
  34. /*  this example shows the usage of this commands                         */
  35. /*       this example connects to the user 'test'                         */
  36. /*       waits for a connection                                           */
  37. /*       transfers a file                                                 */
  38. /*       and disconnect                                                   */
  39. /**************************************************************************/
  40.  
  41.  
  42. PIPE = "\PIPE\ISDNPM.CMD"
  43.  
  44.     say
  45.     say "Read the 1st 2nd and 3rd Userentry"
  46.     say
  47.  
  48.     say SendCommandAndWAit("FIRSTUSER")
  49.     say SendCommandAndWAit("NEXTUSER")
  50.     say SendCommandAndWAit("NEXTUSER")
  51.  
  52.     say
  53.     say "show the state of channel 0 and channel 1 "
  54.     say
  55.  
  56.     say SendCommandAndWAit("CHANNELSTATUS 0")
  57.     say SendCommandAndWAit("CHANNELSTATUS 1")
  58.  
  59.  
  60.     say
  61.     say "connect to user test"
  62.     say
  63.  
  64.     say SendCommandAndWAit("CONNECT test")
  65.  
  66.     status = 'R'
  67.  
  68.     do while status <> 'G'
  69.  
  70.         call SysSleep(1)
  71.         cs = SendCommandAndWAit("CHANNELSTATUS test")
  72.  
  73.         parse var CS cmd ch usr status  txc txp rxc rxp dur charge dis l3err
  74.         say status
  75.  
  76.     end
  77.  
  78.     say
  79.     say "wait 5 seconds an then get a file"
  80.     say
  81.  
  82.     call SysSleep(5)
  83.  
  84.     rc = FtpSetUser('ftp.uni-freiburg.de','anonymous','mywi')
  85.     if rc = 1 then do
  86.  
  87.         rc = FtpChdir('pub/pc/os2/isdn')
  88.         rc = Ftpget('isdnpm27.zip','isdnpm27.zip','BINARY')
  89.  
  90.         rc = FtpLogOff()
  91.  
  92.         call SysSleep(10)
  93.  
  94.     end
  95.     say
  96.     say 'now disconnect test'
  97.     say
  98.     say SendCommandAndWAit("DISCONNECT test")
  99.  
  100.  
  101.  
  102. exit 0
  103. /**************************************************************************/
  104. /* send a command to the PIPE and wait for an answer                      */
  105. /**************************************************************************/
  106. SendCommandAndWait:
  107. parse arg Command
  108.  
  109.     rc = SysWaitNamedPipe(PIPE,5000)
  110.     if( rc = 0 )then do
  111.  
  112.         rc = charout(PIPE,Command)
  113.         cnt = 0
  114.         do while cnt == 0
  115.           cnt = chars(PIPE)
  116.         end
  117.         in  = charin(PIPE,,100)
  118.         return in
  119.     end
  120.     else
  121.         return "TIMEOUT"
  122.  
  123.