home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 32 Periodic / 32-Periodic.zip / ez111htm.zip / HOBBEGET.TXT < prev    next >
Text File  |  1996-09-01  |  3KB  |  65 lines

  1. /* NEWHOBBE.CMD
  2. Get description files from /incoming on hobbes.nmsu.edu 
  3. By Dirk Terrell
  4. This code is hereby entered into the public domain.
  5.  
  6. If browsing this file on the WWW, save it to your local hard
  7. drive with a .CMD extension.  If browsing this file in an
  8. off-line version of OS/2 e-Zine!, just rename the file
  9. hobbeget.txt to hobbeget.cmd */
  10.  
  11. rc = RxFuncAdd("FtpLoadFuncs","RxFtp","FtpLoadFuncs") /* Load the FTP library */
  12. rc = FtpLoadFuncs()
  13. /* ftp://software.watson.ibm.com/pub/os2/ews/rxftp.zip */
  14. rc = rxfuncadd('SysLoadFuncs','RexxUtil','SysLoadFuncs') /* Load the system utilities */
  15. rc = sysloadfuncs()
  16.  
  17. Site="hobbes.nmsu.edu"               /* FTP site */
  18. RemoteDir="incoming"                 /* Directory on FTP site */
  19. LocalDir="d:\network\rxftp"          /* Directory to place files in on local machine */
  20. TempFile="newhobbe.txt"              /* The temporary file for the results */
  21. User="anonymous"                     /* Login user ID */
  22. Pass="terrell@gnv.fdt.net"           /* Password, make it your email address */
  23. FileType="Ascii"                     /* We'll be transferring text files */
  24. OldDir=Directory(LocalDir)           /* Change to specified directory */
  25. Say OldDir
  26. if FTPSetUser(Site,User,Pass) then do  /* Successful login to site */
  27.       rc=FTPChDir(RemoteDir)           /* Set the remote directory */
  28.       rc=FTPLs("*.txt",DirList.)       /* Get a listing of files matching *.txt */
  29.       Do i=1 to DirList.0              /* Store the retrieved file names */
  30.          FileList.i=DirList.i
  31.       End
  32.       FileList.0=DirList.0             /* FileList.0 holds the number of files */
  33.       rc=FTPLs("*.TXT",DirList.)       /* Get a listing of files matching *.TXT */
  34.       Do i=1 to DirList.0              /* Store those file names */
  35.          k=i+FileList.0
  36.          FileList.k=DirList.i
  37.       End
  38.       FileList.0=k
  39.       rc=SysFileDelete(TempFile)       /* Delete the temporary file if it exists */
  40.       Do i=1 to FileList.0             /* Loop over all files */
  41.          Test=Translate(FileList.i)    /* Convert filename to uppercase */
  42.          If Test="00INDEX.TXT" | Test="00INDEXD.TXT" then       /* If the file is an index ... */
  43.             Say "Skipping" FileList.i "file" i "of" FileList.0  /*   then skip it */
  44.          else                                                   /* Otherwise do the following */
  45.             Do
  46.                Say "Getting" FileList.i "file" i "of" FileList.0  /* Keep user informed */
  47.                rc=FtpGet(FileList.i,FileList.i,FileType)          /* Get the file */
  48.                rc=Lineout(TempFile," ")                     /* Separator */
  49.                rc=Lineout(TempFile,"*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_")
  50.                rc=Lineout(TempFile,FileList.i)              /* Write file name */
  51.                rc=Lineout(TempFile)                         /* Close the temp. file */
  52.                "@copy" TempFile||"+"||FileList.i "1>nul 2>nul"    /* Append file to temp. file */
  53.                rc=SysFileDelete(FileList.i)                       /* Delete the file */
  54.             End
  55.       end /* do */
  56.       rc=FtpLogOff()                   /* Log off the FTP site */
  57.    End
  58. Else                                   /* Couldn't get logged in */
  59.    Do
  60.       Say "Could not log on to" Site
  61.       Exit
  62.    End
  63. rc=Directory(OldDir)                   /* Change back to original directory */
  64. Exit
  65.