ftp automation

ScriptFTP

The professional tool to automate FTP, SFTP, FTPS and schedule FTP batch jobs

The forum is now read only. Please, go to the the main ScriptFTP website if you need help.
Need help writing a script? Have any question about ScriptFTP?
Hello guys i'm john from france (sorry for my bad english), and i need a bit of help from you on a script please

my script connect a server in a folder
the script download the folder from the day but not the file that are in folders
and i would like to download all the fils contained in the folder
there may be another way to write that won't
FTP Script
  1. SETPROTOCOL(FTPS_EXPLICIT)
  2. SETPORT(57112)
  3. $result=OPENHOST("127.0.0.1","lutin","gros")
  4. IF($result!="OK")
  5.    PRINT("Error connecting to the FTP server. Stopping script.")
  6.    STOP
  7. LOCALCHDIR("E:\vide")
  8. $result=CHDIR("_Archives/test/")
  9. IF($result!="OK")
  10.    PRINT("Error changing current local directory. Stopping script.")
  11.    STOP
  12. $result=GETLIST($myremotefilelist,REMOTE_DIRECTORIES,"*.*")
  13. IF($result!="OK")
  14.    PRINT("Error retrieving remote file listing. Stopping the script")
  15.    STOP
  16. $currenttime=GETDATE(FORMAT0)
  17. $currentdate=TEXTCUT($currenttime,1,10)
  18. FOREACH $remotefile IN $myremotefilelist
  19.    $filetime=GETFILETIME(REMOTE,$remotefile)
  20.    IF($result!="OK")
  21.       PRINT("Error getting the remote file time of ".$remotefile.". Stopping the script.")
  22.       STOP
  23.    END IF
  24.    $filedate=TEXTCUT($filetime,1,10)
  25.    # Check if the file has been created today
  26.    IF($filedate==$currentdate)
  27.        PRINT("The file ".$remotefile." has been created today. Downloading.")
  28.        # The file has been created or modified today. Download it.
  29.        $result=GETFILE($remotefile)
  30.        # -------------------------------- Don't work
  31.        CHDIR("_Archives/test/$remotefile")    
  32.        # -------------------------------- Don't work
  33.        GETFILE("*.*")
  34.        # ------------------------------- Don't work
  35.        CHDIR("_Archives/test/")
  36.        IF($result!="OK")
  37.           PRINT("Error downloading ".$remotefile.". Stopping the script.")
  38.           STOP
  39.       END IF
  40.     ELSE
  41.         PRINT("The file ".$remotefile." has NOT been created today. Skipping.")
  42.      END IF
it runs
FTP Script
  1. SETPROTOCOL(FTPS_EXPLICIT)
  2. SETPORT(57112)
  3. $result=OPENHOST("127.0.0.1","lutin","gros")
  4. IF($result!="OK")
  5.    PRINT("Error connecting to the FTP server. Stopping script.")
  6.    STOP
  7. LOCALCHDIR("E:\vide")
  8. $result=CHDIR("_Archives/test/")
  9. IF($result!="OK")
  10.    PRINT("Error changing current local directory. Stopping script.")
  11.    STOP
  12. $result=GETLIST($myremotefilelist,REMOTE_DIRECTORIES,"*.*")
  13. IF($result!="OK")
  14.    PRINT("Error retrieving remote file listing. Stopping the script")
  15.    STOP
  16. $currenttime=GETDATE(FORMAT0)
  17. $currentdate=TEXTCUT($currenttime,1,10)
  18. FOREACH $remotefile IN $myremotefilelist
  19.    $filetime=GETFILETIME(REMOTE,$remotefile)
  20.    IF($result!="OK")
  21.       PRINT("Error getting the remote file time of ".$remotefile.". Stopping the script.")
  22.       STOP
  23.    END IF
  24.    $filedate=TEXTCUT($filetime,1,10)
  25.    # Check if the file has been created today
  26.    IF($filedate==$currentdate)
  27.        PRINT("The file ".$remotefile." has been created today. Downloading.")
  28.        # The file has been created or modified today. Download it.
  29.       $result=GETFILE($remotefile)
  30.       CHDIR($remotefile)
  31.       LOCALCHDIR($remotefile)
  32.       GETFILE("*.*")
  33.       CHDIR("..")
  34.       LOCALCHDIR("E:\vide")
  35.       IF($result!="OK")
  36.            PRINT("Error downloading ".$remotefile.". Stopping the script.")
  37.            STOP
  38.       END IF
  39.    ELSE
  40.        PRINT("The file ".$remotefile." has NOT been created today. Skipping.")
  41.    END IF
Hi, thanks for posting here.

I have seen you used:

[ScriptFTP]CHDIR("..")[/ScriptFTP]

in the latest script. Yes, that is the correct way to go to the parent director. :)
Yes i have use ".." because in batch we write this "cd.." and it Work good :) but my new error i have not solve for the moment ...