home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 3 Comm / 03-Comm.zip / autozoc3.zip / OS2NEW.REX < prev    next >
OS/2 REXX Batch file  |  1996-09-01  |  5KB  |  195 lines

  1. /* REXX script to automatically call BBS, log on, download OS2NEW.ZIP, then log off. */
  2.  
  3. /* clear screen  */
  4. CALL ZocCls
  5.  
  6. /* set variables */
  7.  
  8. user_name="XXXX XXXXXXXX"       /* your name as registered with the BBS (put in quotes) */
  9. password="XXX##XX"              /* your password as registered with the BBS (put in quotes) */
  10. bbs_num="#-###-###-####"        /* the BBS phone number (put in quotes) */
  11. min_speed=#####                 /* minimum connect speed you'll accept (NO QUOTES) */
  12. max_attempts=#                  /* maximum number of times to retry the call (NO QUOTES) */
  13.  
  14. DO call_bbs=1 TO max_attempts
  15.  
  16.   /* clear screen */
  17.   CALL ZocCls
  18.  
  19.   /* initialize modem */
  20.   CALL ZocSend "ATZ1^M"
  21.   CALL ZocDelay 1
  22.  
  23.   SAY "Attempt # " call_bbs 
  24.  
  25.   SAY "Calling the OS/2 Shareware BBS to download OS2NEW.ZIP.  Dialing...." bbs_num
  26.  
  27.   CALL ZocTimeOut 60
  28.  
  29.   CALL ZocDial bbs_num "^IOS/2 Shareware"
  30.  
  31.       /* let's see what kind of response we get */
  32.       DO result_type=1 TO 6
  33.  
  34.          /* receive next line of text */
  35.          rc=ZocGetLine()
  36.  
  37.          /* if no answer, try again (leave loop) */
  38.          IF rc=640 THEN 
  39.          DO
  40.             CALL ZocHangup
  41.             LEAVE result_type
  42.          END
  43.          
  44.          /* if BUSY was received, try again (leave loop) */
  45.          IF ZocLastLine()="BUSY" THEN
  46.          DO
  47.         CALL ZocDelay 1
  48.         CALL ZocMsgBox "The line is busy.  We'll try again.", 0
  49.             LEAVE result_type
  50.          END
  51.  
  52.          /* if NO DIAL TONE was received, end with error message */
  53.          IF ZocLastLine()="NO DIAL TONE" THEN 
  54.          DO
  55.         CALL ZocDelay 1
  56.             CALL ZocMsgBox "Possible hardware or software trouble.  Aborting attempt.", 1
  57.             EXIT
  58.          END
  59.  
  60.          /* if NO CARRIER was received, end with error message */
  61.          IF ZocLastLine()="NO CARRIER" THEN 
  62.          DO
  63.             CALL ZocHangup
  64.             CALL ZocMsgBox "Possible dialing error.  Check phone number.", 1
  65.             EXIT
  66.          END
  67.  
  68.          /* determine the connect speed */
  69.          DO b=9 TO 15
  70.            IF SUBSTR(ZocLastLine(),b,1)="/" THEN
  71.            DO 
  72.               b=b-9
  73.               LEAVE b
  74.            END
  75.          END b
  76.          speed=SUBSTR(ZocLastLine(),9,b)
  77.          IF speed<min_speed THEN 
  78.          DO
  79.             CALL ZocHangup
  80.             ans=ZocMsgBox("Connect speed is too slow!  Do you want to try again?", 2)
  81.             IF ans="##NO##" THEN EXIT
  82.                ELSE LEAVE result_type
  83.          END
  84.          ELSE LEAVE call_bbs
  85.  
  86.       END result_type
  87.  
  88.       IF call_bbs<max_attempts THEN
  89.       DO
  90.     DO time_out=30 to 1 by -1
  91.       IF time_out>1 THEN CALL ZocNotify "Pausing " time_out " seconds."
  92.          ELSE CALL ZocNotify "Pausing " time_out " second."
  93.       Call ZocDelay 1
  94.     END time_out
  95.       END
  96.  
  97. END call_bbs
  98.  
  99. IF call_bbs=max_attempts+1 THEN
  100. DO
  101.    CALL ZocMsgBox "Can't get through now.....try again later.", 0
  102.    CALL ZocCls
  103.    CALL ZocSend "ATZ1^M"
  104.    CALL ZocDelay 1
  105.    EXIT
  106. END
  107.  
  108. CALL ZocTimeOut 10
  109. rc=ZocGetLine()
  110. IF rc=640 THEN SIGNAL PROBLEM
  111.  
  112. CALL ZocWait "your name:"
  113. CALL ZocSend user_name "^M"
  114.  
  115. CALL ZocTimeOut 05
  116. rc=ZocGetLine()
  117. IF rc=640 THEN SIGNAL PROBLEM
  118.  
  119. CALL ZocWait SUBSTR(user_name,LENGTH(user_name)-2,3)' [Y,n]?'
  120. CALL ZocSend "y^M"
  121.  
  122. CALL ZocTimeOut 05
  123. rc=ZocGetLine()
  124. IF rc=640 THEN SIGNAL PROBLEM
  125.  
  126. CALL ZocWait "Password:"
  127. CALL ZocSend password "^M"
  128.  
  129. CALL ZocTimeOut 05
  130. rc=ZocGetLine()
  131. IF rc=640 THEN SIGNAL PROBLEM
  132.  
  133. CALL ZocWait "o continue"
  134. CALL ZocSend "^M"
  135.  
  136. Call ZocTimeOut 05
  137. rc=ZocGetLine()
  138. IF rc=640 THEN SIGNAL PROBLEM
  139.  
  140. CALL ZocWait "e [Y,n,=]?"
  141. CALL ZocSend "N^M"
  142.  
  143. Call ZocTimeOut 05
  144. rc=ZocGetLine()
  145. IF rc=640 THEN SIGNAL PROBLEM
  146.  
  147. CALL ZocWait "Select: "
  148. CALL ZocSend "F^M"
  149.  
  150. CALL ZocTimeOut 05
  151. rc=ZocGetLine()
  152. IF rc=640 THEN SIGNAL PROBLEM
  153.  
  154. CALL ZocWait "Select: "
  155. CALL ZocSend "D^M"
  156.  
  157. CALL ZocTimeOut 60
  158.  
  159. CALL ZocWait "load (#1):"
  160. CALL ZocSend "OS2NEW.ZIP^M"
  161.  
  162. CALL ZocWait "load (#2):"
  163. CALL ZocSend "/G^M"
  164.  
  165. result=ZocWaitMux("<esc> to abort:", "Disconnect [Y,n,?=help]? ", "Transfer completed.")
  166.   SELECT
  167.     WHEN result=0 THEN Call ZocSend "^M"
  168.     WHEN result=1 THEN SIGNAL ALREADY_GOT_1
  169.     WHEN result=2 THEN SIGNAL ALREADY_GOT_2
  170.   END
  171.  
  172.  
  173. ALREADY_GOT_1:
  174.   CALL ZocSend "Y^M"
  175.   CALL ZocDelay 1
  176.   CALL ZocSend "N^M"
  177.   CALL ZocDelay 1
  178.   CALL ZocHangup
  179.   EXIT
  180.  
  181. ALREADY_GOT_2:
  182.   CALL ZocSend "G^M"
  183.   CALL ZocDelay 1
  184.   CALL ZocSend "Y^M"
  185.   CALL ZocDelay 1
  186.   CALL ZocSend "N^M"
  187.   CALL ZocDelay 1
  188.   CALL ZocHangup
  189.   EXIT
  190.  
  191. PROBLEM:
  192.    CALL ZocHangup
  193.    CALL ZocMsgBox "Something went wrong", 1
  194.    EXIT
  195.