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

Register 
注册
Search 搜索
首页 
Home Home
Software
Upload

  
/* An example of using the RexxInet functions to download a file
 * from the internet using Ftp protocol and save it to a file on
 * disk.
 */


/* ========================= 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 ==========================
 * Download the file.
 */

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

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

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

/* Download the file README.TXT from that directory and save
 * it on the local drive as "README.TXT" in the temp directory.
 */
inetfile("README.TXT", SEARCHPATH("%TEMP%") || "README.TXT")

/* If desired, you can now download another file from the same
 * FTP server by doing another FtpGetFile(). If the file is in
 * a different directory, you should do an InetDir() "SET" call
 * first to set that directory as the current.
 */

/* Close that Ftp handle. */
inetclose("MyFtpHandle")

/* If desired, you can now download another file from a different
 * FTP server by looping back to InetConnect() and passing it
 * a different FTP server.
 */

/* 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()
掌柜推荐
 
 
 
 
 
 
 
 
 
 
 
 
© Fri 2024-3-29  Guidance Laboratory Inc.
Email:webmaster1g.yi.org Hits:0 Last modified:2010-07-16 20:45:40