home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 3 Comm / 03-Comm.zip / NSCKWQ.ZIP / IbmNsc.cmd
OS/2 REXX Batch file  |  1992-12-06  |  8KB  |  246 lines

  1. /*------------------------------------------------------------------*/
  2. /* Log onto IBM NSC BBS, send pending QWK messages and download new.*/
  3. /* The script assumes your settings on the board include:           */
  4. /*                   expert toggled on.                             */
  5. /*                                                                  */
  6. /* Use of Zmodem has been replaced with YModemG here because of     */
  7. /* problems the NSC QWK support seems to have with Zmodem.          */
  8. /*                                                                  */
  9. /* Timeouts are set assuming a reasonable number of new messages.   */
  10. /* If your last message in each forum isn't reasonably current,     */
  11. /* you'll time out.                                                 */
  12. /*                                                                  */
  13. /* This script assumes you have set the PmComm32 memo field to a    */
  14. /* string that consists of "First name", "Last Name", and "Password"*/
  15. /* separated by white space.  Example:                              */
  16. /*                                                                  */
  17. /*                    Ron Hester mysecretpassword                   */
  18. /*                                                                  */
  19. /* Be sure to set "Conferences" and "Reply_File", below, to relect  */
  20. /* your system and interests.                                       */
  21. /*------------------------------------------------------------------*/
  22.  
  23. /* User info */
  24.  
  25. Conferences = '6 30 36 1 18 3 4 5'  /* List of conferences to capture */
  26. Reply_File="D:\PmComm\HostUp\NscBBS.rep" /* Packet to upload */
  27.  
  28. /* Switches */
  29. dcds = 1                          /* If modem supports dcd */
  30. Use_Alarm = 1                     /* Use completion sounds */
  31.  
  32. Signal ON SYNTAX NAME SYNTAX_ERROR
  33.  
  34. Parse arg port portname screen_handle dde_output dde_input semaphore
  35. Parse source . . fn .
  36.  
  37. /* Constants */
  38. cr     = '0d'x
  39. crlf   = '0a0d'x
  40. ctrl_K = '0b'x
  41.  
  42. Call RxFuncAdd "Init_32dll","RxPmC32","Init_32dll"
  43. Call Init_32dll
  44. Call RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs'
  45. Call SysLoadFuncs
  46. Call Clear
  47. Call Alarm
  48. Call Put_s 'Executing' fn '...'crlf,screen_handle
  49.  
  50. Call get_dial_memo dde_output,dde_input
  51. parse var Result First_Name Last_Name Password
  52.  
  53. Call Read_timeout '60000',port
  54.  
  55. If dcds then Call Connected
  56. Call Wait_fore 'First Name->',port,screen_handle
  57. If result=0 then
  58.    Do
  59.       Call Alarm
  60.       Call Put_s crlf"Wait for 'First Name->' prompt has timed out -- disconnecting"crlf,screen_handle
  61.       If dcds then Call Connected
  62.       Exit
  63.    End
  64.  
  65. Call Flush
  66. Call Put_s First_Name";"Last_Name";"Password||cr,port
  67.  
  68. Do Forever
  69.    If dcds then Call Connected
  70.    Call Wait_fore " to continue?",,      /* 1 */
  71.                   "ontinue?",,           /* 2 */
  72.                   "ulletins updated",,   /* 3 */
  73.                   " to abort scan.",,    /* 4 */
  74.                   "execute ?",,          /* 5 */
  75.         port,screen_handle
  76.    Match=Result
  77.    If Match\=4 then Call Flush
  78.    Select
  79.       When Match=1 then Call Put_s cr,port
  80.       When Match=2 then Call Put_s "n",port
  81.       When Match=3 then
  82.          Do
  83.             Call Put_s "n"cr,port
  84.             Leave
  85.          End
  86.       When Match=4 then Call Put_s ctrl_K,port
  87.       When Match=5 then Leave
  88.       Otherwise
  89.          Call Timeout
  90.    End
  91. End
  92.  
  93. If dcds then Call Connected
  94.  
  95. if stream(Reply_File,'c','query exists')\='' then
  96.    do
  97.      If dcds then Call Connected
  98.      Call put_s 'rep'cr,port
  99.      Call Read_timeout '120000',port
  100.      Call Wait_fore "abort:",port,screen_handle
  101.      Call Flush
  102.      Call Put_s "g"cr,port
  103.      Call Read_timeout '60000',port
  104.      Call Wait_fore " format...",port,screen_handle
  105.      Call Flush
  106.      Call YmodemG_send Reply_File,dde_output,dde_input
  107.      Call put_s crlf'RC from Delete='SysFileDelete(Reply_File)||crlf,screen_handle
  108.      If dcds then Call Connected
  109.      Call Wait_fore "execute ?",,
  110.           port,screen_handle
  111.      Call Flush
  112.    end
  113.  
  114. /*---------------------------------------------------------------*/
  115. /* This convoluted block of code tries to cope with the tendency */
  116. /* to skip right over the reply and treat it as a "R"ead request */
  117. /*---------------------------------------------------------------*/
  118. Call put_s 'qwk'cr,port
  119. Call Read_timeout '90000',port
  120. Call wait_fore 'quit?',,                 /* 1 */
  121.                'e(s)?',,                 /* 2 */
  122.      port,screen_handle
  123. Match=Result
  124. Call Flush
  125. Select
  126.    When Match=1 then
  127.      nop
  128.    When Match=2 then                     /* try to resynch */
  129.       Do
  130.         Call put_s 'q'cr,port
  131.         Call Wait_fore "execute ?",,
  132.              port,screen_handle
  133.         Call Flush
  134.         Call put_s 'qwk'cr,port
  135.         Call wait_fore 'quit?',,         /* 1 */
  136.              port,screen_handle
  137.         Call Flush
  138.       End
  139.    Otherwise
  140.       Call Timeout
  141. End
  142.  
  143. If dcds then Call Connected
  144.  
  145. Call put_s 'nnn'cr,port       /* The extra n's help avoid a problem */
  146. Call wait_fore 'quit?',port,screen_handle
  147. Call Flush
  148. Call put_s Conferences||cr,port
  149.  
  150. Call Read_timeout '90000',port
  151. Do Forever
  152.    If dcds then Call Connected
  153.    Call Wait_fore "canning message",,     /* 1 */
  154.                   "Creating QWK",,        /* 2 */
  155.         port,screen_handle
  156.    Match=Result
  157.    If Match=1 then Iterate               /* More time for new Scan */
  158.    Call Flush
  159.    If Match=2 then Leave                 /* Ready to download */
  160.    Call Timeout
  161. End
  162.  
  163. Call Read_timeout '180000',port
  164. Call Wait_fore "abort:",port,screen_handle
  165. Call Flush
  166. Call Put_s "g"cr,port
  167. Call Read_timeout '45000',port
  168. Call Wait_fore ").",port,screen_handle
  169. Call Flush
  170. Call Put_s crlf'Starting YmodemG Receive'crlf,screen_handle
  171. Call YmodemG_receive dde_output,dde_input
  172.  
  173. Call Wait_fore "execute ?",port,screen_handle
  174. Call Flush
  175. Call Put_s "g"cr,port
  176.  
  177. Call Alarm
  178. Exit
  179.  
  180.  
  181. Timeout:
  182.  
  183. If dcds then Call Connected           /* Timeout */
  184. Call Alarm
  185. Call Put_s crlf"Unexpected timeout, script is exiting"crlf,,
  186.      screen_handle
  187. Call Alarm
  188. Exit
  189.  
  190. /* Clear Screen Routine                                              */
  191. Clear: procedure expose screen_handle
  192.  
  193. Call put_s "1b5b324a"x,screen_handle
  194. Return
  195.  
  196.  
  197. /* A Procedure to see if the modem supports DCD and if see if we     */
  198. /* have a connection, if not then DROP the DTR and then RAISE the    */
  199. /* DTR again ...                                                     */
  200. Connected: procedure expose port crlf screen_handle
  201.  
  202. Call DCD port
  203. If result \= 1 then
  204.    Do
  205.      Call Beep 40,900
  206.      Call Put_s 'No Data Carrier Detect ...'||crlf,screen_handle
  207.      Call Drop_DTR port
  208.      Call Raise_DTR port
  209.      Say 'Script ended   -' date() time()
  210.      Exit
  211.    End
  212. Return
  213.  
  214. /*  read through the rest of the buffer and display any characters */
  215. /*       that remain after the wait_fore string */
  216.  
  217. Flush: procedure expose port screen_handle
  218.  
  219. Do while char_avail(port)>0
  220.    Call Put_s Get_ch(port),screen_handle
  221. End
  222. return
  223.  
  224.  
  225. /* speedy NBC noise, courtesy of Dr. Scott Mack */
  226. Alarm:
  227.  
  228. if Use_Alarm then
  229.   do
  230.     call beep 196,350
  231.     call beep 330,500
  232.     call beep 262,650
  233.   end
  234. return
  235.  
  236.  
  237. /* Standard handler for SIGNAL on ERROR, will help in the debuging   */
  238. syntax_error:
  239. fp = filespec("path",fn)
  240. fd = filespec("drive",fn)
  241. errormsg='REXX error' rc 'in line' sigl':' errortext(rc)
  242. errorfile = fd||fp||"SCRIPT.ERR"
  243. rc = lineout(errorfile,date() time() fn '-' errormsg)
  244. rc = lineout(errorfile,date() time() fn '-' sourceline(sigl))
  245. Exit
  246.