home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 3 Comm / 03-Comm.zip / pmcom233.zip / MAIL.CMD < prev    next >
OS/2 REXX Batch file  |  1996-01-02  |  8KB  |  192 lines

  1. /* Sample REXX Script for Multi-Net BBS                              */
  2. /* This script will allow you to log on to IBM NSC BBS once you      */
  3. /* change the strings stored in the varibles NAME and PASS. Enter    */
  4. /* the mail.cmd name for the script name of the IBM NSC BBS phone    */
  5. /* number.                                                           */
  6.  
  7. Signal ON SYNTAX NAME SYNTAX_ERROR
  8.  
  9. Parse arg port portname screen_handle dde_output dde_input semaphore
  10. Parse source . . fn .
  11. /*These are the values that Pmcomm passes on the command line to and */
  12. /* external program. These values can then be used in different REXX */
  13. /* functions along with the rxpmcomm.dll functions. Following is the */
  14. /* description of each value:                                        */
  15. /*      port = The handle of the open com port in Pmcomm             */
  16. /*      portname = The name of the opened com port ie.. COM1         */
  17. /*      screen_handle = Anything written to the handle will be       */
  18. /*                      printed on the Pmcomm screen.                */
  19.  
  20. /* Setup variables                                                   */
  21. name = 'first;last'               /* name  first;last                */
  22. pass = 'password'                 /* password                        */
  23. cr   = '0D'x
  24. crlf = '0A0D'x
  25. dcds = 1                          /* 0=no DCD support  1=DCD support */
  26.  
  27. /* This function registers the init_dll function with REXX. The      */
  28. /* init_dll function will register the rest of the functions in      */
  29. /* the rxpmcomm.dll.                                                 */
  30. Call RxFuncAdd "init_dll","RxPmcomm","init_dll"
  31.  
  32. /* Required before any other rxpmcomm.dll functions are called.      */
  33. Call init_dll
  34. Call Clear
  35.  
  36. /* This will be printed on the REXX session screen                   */
  37. Say 'Script started -' date() time()
  38. Call Put_s 'Executing' fn '...'||crlf,screen_handle
  39.  
  40. /* This sets the read timeout for 20 seconds. This is used in the    */
  41. /* wait_for, wait_fore, and the Get_ch functions.                    */
  42. Call Read_timeout '20000',port
  43.  
  44. If dcds then Call Connected
  45.  
  46. Say 'Waiting for first name ...'
  47. Do Forever
  48.    Call Wait_fore 'Name','Password','continue?','execute ?','[N]o, [C]',port,screen_handle
  49.  
  50. /* This call will echo all characters to the Pmcomm screen that come */
  51. /* from the open com port. When one of the strings are matched the   */
  52. /* function will return the index of the matched string in the       */
  53. /* variable result. For example if it receives the string password   */
  54. /* then result will be equal to 2. If the functions waits longer     */
  55. /* then the read timeout value then result will be equal to 0.       */
  56.  
  57.    match = result
  58.    Select
  59.      When match=1 then
  60.        Do
  61.          Call Put_s name||cr,port
  62.          Say 'Waiting for password ...'
  63.        End
  64.      When match=2 then Call Put_s pass||cr,port
  65.      When match=3 then Call Put_s cr,port
  66.      When match=4 then Leave
  67.      When match=5 then Call Put_s 'N',port
  68.    Otherwise nop
  69.    End
  70. End
  71. /* This will capture New mail from conference 1. The choices are Y for*/
  72. /* your, N for new, and A for all. If you want to capture mail in more */
  73. /* then one conference, then list the following function for each      */
  74. /* conference. If you want to capture all the new mail in all conferences*/
  75. /* use this: Parse value read_mail("N" "A") with rc                    */
  76.  
  77. Parse value read_mail("N" 1) with rc
  78. If rc = 0 then Call file_transfer(zmodem download)
  79.  
  80. Say 'Script ended   -' date() time()
  81. Exit
  82.  
  83.  
  84. /* Clear Screen Routine                                              */
  85. Clear: procedure expose screen_handle
  86.  
  87. Call put_s "1b5b324a"x,screen_handle
  88. Return
  89.  
  90.  
  91. /* A Procedure to see if the modem supports DCD and if see if we     */
  92. /* have a connection, if not then DROP the DTR and then RAISE the    */
  93. /* DTR again ...                                                     */
  94. Connected: procedure expose port crlf screen_handle
  95.  
  96. Call DCD port
  97. If result \= 1 then
  98.    Do
  99.      Call Beep 40,900
  100.      Call Put_s 'No Data Carrier Detect ...'||crlf,screen_handle
  101.      Call Drop_DTR port
  102.      Call Raise_DTR port
  103.      Say 'Script ended   -' date() time()
  104.      Exit
  105.    End
  106. Return
  107.  
  108. /* Standard handler for SIGNAL on ERROR, will help in the debuging   */
  109. syntax_error:
  110. fp = filespec("path",fn)
  111. fd = filespec("drive",fn)
  112. errormsg='REXX error' rc 'in line' sigl':' errortext(rc)
  113. errorfile = fd||fp||"SCRIPT.ERR"
  114. rc = lineout(errorfile,date() time() fn '-' errormsg)
  115. rc = lineout(errorfile,date() time() fn '-' sourceline(sigl))
  116. Exit
  117.  
  118.  
  119. /* Standard file transfer routine for all protocols that PMCOMM has  */
  120. File_Transfer: procedure expose cr crlf dde_output dde_input semaphore port screen_handle
  121. Parse arg protocol  direction
  122.  
  123. Call Read_timeout '5000',port
  124. Call Put_s "d m"||crlf,port
  125. Call Wait_fore "to quit?",port,screen_handle
  126. Call Put_s "b"||crlf,port
  127. Select
  128.     When protocol = "XMODEM" & direction = "DOWNLOAD"  then
  129.          do
  130.          Call wait_fore "[Return] to abort",port,screen_handle
  131.          If result = 1 then Call put_s "X" || crlf,port
  132.             Call wait_fore "[Return]?",port,screen_handle
  133.             Call put_s "Y" || crlf,port
  134.             Call xmodem_receive file_name,dde_output,dde_input
  135.          end
  136.     When protocol = "XMODEM-1K" & direction = "DOWNLOAD"  then
  137.          do
  138.          Call wait_fore "[Return] to abort",port,screen_handle
  139.          If result = 1 then Call put_s "C" || crlf,port
  140.             Call wait_fore "[Return]?",port,screen_handle
  141.             Call put_s "Y" || crlf,port
  142.             Call xmodem_1k_receive file_name,dde_output,dde_input
  143.          end
  144.     When protocol = "YMODEM" & direction = "DOWNLOAD"  then
  145.          do
  146.          Call wait_fore "[Return] to abort",port,screen_handle
  147.          If result = 1 then Call put_s "Y" || crlf,port
  148.             Call wait_fore "[Return]?",port,screen_handle
  149.             Call put_s "Y" || crlf,port
  150.             Call ymodem_receive dde_output,dde_input
  151.          end
  152.     When protocol = "YMODEMG" & direction = "DOWNLOAD"  then
  153.          do
  154.          Call wait_fore "[Return] to abort",port,screen_handle
  155.          If result = 1 then Call put_s "G" || crlf,port
  156.             Call wait_fore "[Return]?",port,screen_handle
  157.             Call put_s "Y" || crlf,port
  158.             Call ymodemg_receive dde_output,dde_input
  159.          end
  160.     When protocol = "ZMODEM" & direction = "DOWNLOAD"  then
  161.          do
  162.            Call wait_fore "[Return] to abort",port,screen_handle
  163.            If result = 1 then Call put_s "Z" || crlf,port
  164.               Call wait_fore "[Return]?",port,screen_handle
  165.               Call put_s "Y" || crlf,port
  166.               Call zmodem_receive dde_output,dde_input
  167.          end
  168.     Otherwise nop
  169.     End
  170. Call Read_timeout '20000',port
  171. return
  172.  
  173.  
  174. /* Capture the mail ( All, New, Your ) for given conference(s) for   */
  175. /* download and offline reading.                                     */
  176. Read_Mail: procedure expose cr crlf dde_output dde_input port screen_handle
  177. Parse arg type conference
  178.  
  179. Call Read_timeout '30000',port
  180. Do i=1 by 1 to words(conference)
  181.    Call Put_s "CA"||crlf,port
  182.    Call Wait_fore "to quit?",port,screen_handle
  183.    If result = 0 then return 99
  184.    Call Put_s type crlf,port
  185.    Call Wait_fore "to quit?",port,screen_handle
  186.    If result = 0 then return 99
  187.    Call Put_s word(conference,i)||crlf,port
  188.    Call Wait_fore "? ",port,screen_handle
  189.    If result = 0 then return 99
  190.    return 0
  191. End
  192.