Guidance
指路人
g.yi.org
Software / Reginald / Examples / ftpdirlist.rex

Register 
新用户注册
Search 搜索
首页 
Home Home
Software
Upload

  
/* An example of using the RexxInet functions to list a directory
 * on an Ftp site.
 */



/* ========================= STEP 1 ==========================
 * Load RexxInet functions. Set up error handling for RexxInet.
 * Have it raise ERROR condition. This is done once at the
 * start of our script.
 */

/* Load REXXINET.DLL and register all its functions. */
LIBRARY rexxinet
ineterr = "ERROR"
inetheading = 1








/* ========================= STEP 2 ==========================
 * Make sure we're connected to the internet (if a dial-up
 * account), and initialize RexxInet.
 */

DO
   /* Make sure we're connected to the internet. If not,
    * automatically connect the default account.
    */
   inetdial("ONLINE")

   /* Initialize REXXINET. We tell WinINet that our script name is "My test" */
   inetopen(, , "My test")

   /* Let's CATCH ERROR so we don't have to error check
    * any of the above calls to RexxINet functions. Yay!
    */
   CATCH ERROR
      CONDITION('M')
      RETURN
END








/* ========================= STEP 3 ==========================
 * List the contents of a directory.
 */

/* Here's the FTP server hosting the files/dirs I want to list.
 * I could pass this directly to InetConnect if desired.
 */
myftpsite = "ftp.microsoft.com"

/* Connect to the server, and save the handle in "MyFtpHandle". */
inetconnect("MyFtpHandle", myftpsite, "FTP")

/* Set the current directory to "peropsys". */
inetdir("peropsys")

/* Get the next file/dir and store information in the variable
 * "dirInfo". Note: If there are no more matching files, then
 * "DONE" is returned. NOTE: No condition is raised in that
 * event, even if we've set InetErr to do so for errors.
 */
DO WHILE inetmatchname("dirInfo") == ""

   /* Display the name. */
   CHAROUT(, dirinfo)

   /* If it's a directory, display <DIR>. */
   flag = BIT(dirinfo.2, 4)
   IF flag THEN SAY " <DIR>"
   ELSE SAY

END

/* If desired, you can now enumerate another dir from the same
 * FTP server by doing another InetMatchName() on that directory
 * name. You should use InetDir to set to that directory. If you
 * wish to enumerate files/dirs on a different server, then you
 * should also do a InetClose("MyFtpHandle") first.
 */

/* Done */
RETURN










/* ================ Error handling and cleanup ================ */

CATCH ERROR
   CONDITION('M')

FINALLY
   /* Terminate use of RexxInet and disconnect from the internet.
    * NOTE: If our main script ends without doing this, then
    * RexxInet implicitly does this for us.
    */
   inetclose()
掌柜推荐
 
 
 
 
 
 
 
 
 
 
 
 
© Sat 2017-6-24  Guidance Laboratory Inc.
Email:webmaster1g.yi.org Hits:0 Last modified:2010-07-16 20:45:40