home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 18 REXX / 18-REXX.zip / rexxftp.zip / AUTOFTP.CMD next >
OS/2 REXX Batch file  |  1996-03-16  |  4KB  |  132 lines

  1. /* REXX   ---------------------------------------------------------
  2.  * AutoFTP.cmd :
  3.  *------------------------------------------------------------------
  4.  * 03-16-93 originally by Patrick J. Mueller & Cliff Nadler
  5.  * 03-16-96 Modified by Jason I. Glithero
  6.  *------------------------------------------------------------------*/
  7.  
  8. trace off
  9.  
  10. /*------------------------------------------------------------------
  11.  * load functions, if needed
  12.  *------------------------------------------------------------------*/
  13. if RxFuncQuery("FtpLoadFuncs") then
  14.    do
  15.    rc = RxFuncAdd("FtpLoadFuncs","RxFtp","FtpLoadFuncs")
  16.    rc = FtpLoadFuncs()
  17.    end
  18.  
  19. if RxFuncQuery("SysLoadFuncs") then
  20.    do
  21.    rc = RxFuncAdd("SysLoadFuncs","RexxUtil","SysLoadFuncs")
  22.    rc = SysLoadFuncs()
  23.    end
  24.  
  25. /*------------------------------------------------------------------
  26.  * set up signal
  27.  *------------------------------------------------------------------*/
  28. signal on halt
  29.  
  30. parse value SysTextScreenSize() with rows cols
  31.  
  32. /*------------------------------------------------------------------
  33.  * get parameters
  34.  *------------------------------------------------------------------*/
  35. parse arg host user pass .
  36.  
  37. /*------------------------------------------------------------------
  38.  * set things
  39.  *------------------------------------------------------------------*/
  40.  
  41. InfoFile = "Info.txt"
  42.  
  43. host = LINEIN(InfoFile)    /* Gets the first line of info.txt */
  44. user = LINEIN(InfoFile)
  45. pass = LINEIN(InfoFile)
  46. hostdir = LINEIN(InfoFile)
  47.  
  48. rc = FtpSetUser(host,user,pass)
  49. err = FtpChDir(hostdir)
  50.  
  51.    if (host <> "") then
  52.       status = "connected to" user"@"host
  53.    else
  54.       status = "not connected to a host"
  55.  
  56.    junk = FtpPwd('dir')
  57.    if (junk <> 0) then
  58.       dir = "not specified"
  59.  
  60.    say d2c(218) || copies(d2c(196),70)
  61.    say d2c(179) || " AutoFtp:" time() status
  62.    say d2c(179) || " directory:" dir
  63.    say d2c(192) || copies(d2c(196),70)
  64.  
  65.    /*---------------------------------------------------------------
  66.     * Download command
  67.     *---------------------------------------------------------------*/
  68.    
  69.    DownLoadFile = "FileList.txt"
  70.    GetFile = LINEIN(DownLoadFile)
  71.    
  72.    do while  GetFile <> ""
  73.      say 'Downloading . . . . . ' GetFile 
  74.      rc = FtpGet("e:\tmp\"GetFile ,GetFile ,"BINARY")
  75.      GetFile = LINEIN(DownLoadFile)
  76.    end /* do */
  77.  
  78.    rc = FtpLogoff()
  79.    host = ""
  80.    user = ""
  81.    pass = ""
  82.  
  83. /*------------------------------------------------------------------
  84.  * quit
  85.  *------------------------------------------------------------------*/
  86. done:
  87. rc = FtpSetUser("X","X","X")
  88. rc = FtpLogoff()
  89. exit
  90.  
  91. /*------------------------------------------------------------------
  92.  * break condition
  93.  *------------------------------------------------------------------*/
  94. halt:
  95.    say "Terminating ..."
  96.    signal done
  97.  
  98. /*------------------------------------------------------------------
  99.  * some simple help
  100.  *------------------------------------------------------------------*/
  101. Usage: procedure
  102.  
  103.    say "usage:"
  104.    say "   command ..."
  105.    say "is used to run ftp commands on a remote host"
  106.    say
  107.    say "where:"
  108.    say "   command can be one of:"
  109.    say "       connect host user password"
  110.    say "       close"
  111.    say "       site site-command"
  112.    say "       dir pattern"
  113.    say "       ls  pattern"
  114.    say "       get remotefile [localfile]"
  115.    say "       getb remotefile [localfile]"
  116.    say "       put localfile [remotefile]"
  117.    say "       putb localfile [remotefile]"
  118.    say "       uput localfile [remotefile]"
  119.    say "       uputb localfile [remotefile]"
  120.    say "       rename oldname newname"
  121.    say "       delete filename"
  122.    say "       append remotefile [localfile]"
  123.    say "       appendb remotefile [localfile]"
  124.    say "       sys"
  125.    say "       md directory"
  126.    say "       cd directory"
  127.    say "       rd directory"
  128.    say "       pwd"
  129.    say "       quit"
  130.  
  131.    return 0
  132.