home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 3 Comm / 03-Comm.zip / lw321.zip / unix.cmd < prev    next >
OS/2 REXX Batch file  |  1996-03-19  |  4KB  |  113 lines

  1. /* Sample unattended download script */
  2.  
  3. /********************************************************/
  4. /* I wrote this sample script to demonstrate LiveWire's */
  5. /* scripting abilities. This script was written for my  */
  6. /* internet service provider.                           */
  7. /*                                                      */
  8. /* The script does the following:                       */
  9. /*    1. Waits for a specific time                      */
  10. /*    2. Calls my service provider and logs in          */
  11. /*    3. Starts a UNIX shell session                    */
  12. /*    4. Downloads a set of files                       */
  13. /*    5. Tests the success of the download              */
  14. /*    6. Will retry the download up to three times      */
  15. /*    7. Completes on successful download               */
  16. /*                                                      */
  17. /* If you intend to use all or part of this script,     */
  18. /* you will have to modify it to login to your specific */
  19. /* internet service provider. Enjoy!                    */
  20. /*                                                      */
  21. /*                                                      */
  22. /* Provided free for the users of LiveWire for OS/2     */
  23. /********************************************************/
  24.  
  25. /* Turn REXX debug debugging off */
  26. Trace(Off);
  27.  
  28. /* Set timeout */
  29. SetLW(TimeOut,60);
  30.  
  31. /* Set inter-character pacing to 40ms */
  32. SetLW(Pacing,40);
  33.  
  34. /* GLOBAL VARIABLES */
  35. NumberToDial = "555-9109"
  36. LogonName = "xxx"              /* PUT YOUR USER NAME HERE */
  37. Password = "xxxxxxx"           /* PUT YOUR PASSWORD HERE  */
  38. Retries = 3
  39. FilesToDownload = "*.ZIP *.zip"
  40. DownloadHour = 14
  41. DownloadMinute = 23
  42.  
  43. /* Start Logon Session */
  44.     /* Wait for the appointed time */
  45.     ClrScrLW();
  46.     DispLW("Waiting for unattended download at " || DownloadHour || ":" || DownloadMinute || "^M^J");
  47.     WaitTimeLW(DownloadHour, DownloadMinute);
  48.  
  49.     Completed = 0
  50.     Do While ((Retries > 0) & (Completed = 0))
  51.  
  52.        /* Dial to the UNIX host */
  53.        SendLW("ATDT " || NumberToDial || "^M");
  54.        Result = FindLW("CONNECT", "BUSY", "NO CARRIER");
  55.  
  56.        /* Check if we connected */
  57.        if (Result = "CONNECT") then do
  58.  
  59.           /* Attempt the transfer */
  60.           Retries = Retries - 1
  61.  
  62.           /* Login to the UNIX host */
  63.           ret=FindLW("login: ");
  64.           DelayLW(100);
  65.           SendLW(LogonName || "^M");
  66.  
  67.           /* Send password */
  68.           ret=FindLW("^M^JPassword: ");
  69.           DelayLW(100);
  70.           SendLW(Password || "^M");
  71.  
  72.           /* Here we wait to be asked whether we should go to a shell */
  73.           /* account or go into PPP mode, I request shell account     */
  74.           ret=FindLW("Choice [1]: ");
  75.           DelayLW(100);
  76.           SendLW("1^M");
  77.  
  78.           /* At the account menu, I ask to go directly to the shell */
  79.           ret=FindLW("Main Menu]: ^[[0;0;0m[ ]^H^H");
  80.           DelayLW(100);
  81.           SendLW("s");
  82.  
  83.           /* Wait for the shell prompt */
  84.           ret=FindLW("$");
  85.           DelayLW(100);
  86.  
  87.           /* Tell the remote host to begin sending all .ZIP files!  */
  88.           /* Note that we request both upper and lowercase because  */
  89.           /* UNIX is case sensitive */
  90.           SendLW("sz " || FilesToDownload || "^M");
  91.  
  92.           /* Tell LiveWire to begin downloading Zmodem to the       */
  93.           /* default  download path                                 */
  94.           ReceiveResult = ReceiveFilesLW("Z", "");
  95.  
  96.           /* Successful transfer? */
  97.           if (ReceiveResult = "SUCCESS") then do
  98.             Completed = 1;
  99.           End
  100.        End
  101.  
  102.        /* Hangup the phone */
  103.        ret = HangupLW();
  104.  
  105.     End
  106.  
  107.     if (Completed = 0) then
  108.        say "UNSUCCESSFUL DOWNLOAD, please see the log file."
  109.     else
  110.        say "Successful download completed."
  111.  
  112. Exit
  113.