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.
Post here if you experience file transfer problems or unexpected errors.
Now I've got a new problem I ran into, here's the verbose code:

you'll see 6 lines up from the bottom a "Transfer Timeout..."
GETFILE("b_Execs_20081208_COMPANY.csv")
TYPE I
200 Type set to I.
MODE Z
200 MODE Z ok.
PASV
227 Entering Passive Mode (IP,7,218)
Opening data connection to IP Port: 2010
LIST -T
150 Opening ASCII mode data connection for /bin/ls.
226 Transfer complete.
49901 bytes transferred. (51.1 KB/s) (953 ms)
Downloading.................        b_Execs_20081208_COMPANY.csv
SIZE b_Execs_20081208_COMPANY.csv
213 424
PASV
227 Entering Passive Mode (IP,7,208)
Opening data connection to IP Port: 2000
RETR b_Execs_20081208_COMPANY.csv
150 Opening BINARY mode data connection for b_Execs_20081208_COMPANY.csv (424 Bytes).
226 Transfer complete.
Transfer Timeout (30s). Closing data connection.
0 bytes transferred. (0 bytes/s) (00:00:30)
CWD /d:/DAFC_APP/ftp/alaris/EXPORT
250 Directory changed to /d:/DAFC_APP/ftp/COMPANY/EXPORT
PWD
257 "/d:/DAFC_APP/ftp/COMPANY/EXPORT" is current directory.
This situation created a file with 0 bytes of data. The checks I implemented in http://scriptftp.com/forum/viewtopic.php?f=9&t=56 didn't catch this. Any thoughts on how to correct for this situation? Is there a way to parse the verbose output inside of ScriptFTP (preferred) or outside so I can add some error correcting?

Unfortunately some of the files I'm moving can be 0 bytes at times. Is there a way to compare the file size on the server with the received file size?

Thanks!
Hello forest,
any thoughts on how to correct for this situation? Is there a way to parse the verbose output inside of ScriptFTP (preferred) or outside so I can add some error correcting?
150 Opening BINARY mode data connection for b_Execs_20081208_COMPANY.csv (424 Bytes).
226 Transfer complete.
Transfer Timeout (30s). Closing data connection.
In the case you posted, GETFILE should have returned an error. Could you post the complete output? Have GETFILE showed an error like this?
***** Cannot download file bla bla
***** Because bla bla bla

If so, there is no need to parse the verbose output, just adding and IF after GETFILE is enough:
FTP Script
  1. :retrydownload
  2. $result2=GETFILE("b_Execs_".$DATE."_COMPANY.csv")
  3.  
  4. IF($result2!="OK")
  5.    GOTO :retrydownload
Thats the thing..GETFILE didn't return an error...otherwise my if statements would've caught it.

I'll send you the verbose output and my script but please keep each anonymous if you need to post codebits.
Hello Forest,

Thanks for the verbose output.

I've added a new command called GETFILESIZE used to retrieve local and remote file sizes. To use it you have to download and install the ScriptFTP development build:

http://www.ScriptFTP.com/files/ScriptFTP_devel_setup.exe

It is used this way:
FTP Script
  1. # Get the file size (in bytes) of the remote file test1.txt
  2. $result=GETFILESIZE(REMOTE,"test1.txt")
  3.  
  4. # The size is
  5. PRINT($result)
  6.  
  7. # Get the file size (in bytes) of the local file test2.txt
  8. $result=GETFILESIZE(LOCAL,"test2.txt")
  9.  
  10. # The size is
  11. PRINT($result)
  12.  
You can also use paths along with file names:
FTP Script
  1. # Get the file size (in bytes) of the remote file test.txt
  2. GETFILESIZE(REMOTE,"myremotedir/myremotesubdir/test1.txt")
  3.  
On error this command will return a negative value, on success the size in bytes.

The topic in the scripting guide of this command will be added when ScriptFTP 3.2 will be finally released.

Regarding why GETFILE returned OK even when the transfer failed, this is because your server sent a message telling ScriptFTP that the transfer were successful (even when there was a timeout ¿?):
(ScriptFTP) RETR b_Execs_20081208_COMPANY.csv
(FTP server) 150 Opening BINARY mode data connection for b_Execs_20081208_COMPANY.csv (424 Bytes).
(FTP server) 226 Transfer complete.
(ScriptFTP) Transfer Timeout (30s). Closing data connection.
This may have occurred because the file changed its size while it was being downloaded, but I'm not sure.
I've added a new command called GETFILESIZE used to retrieve local and remote file sizes. To use it you have to download and install the ScriptFTP development build: http://www.ScriptFTP.com/ScriptFTP_devel_setup.exe
Hi.

When you give a development build like this, does this build contain all the changes in the previous builds the last weeks?

Lars H.
Hi Lars,

Yes, they contain all the changes.
Awesome! Thanks for the response! My clients will be way happier now. :D Looking forward to 3.2! I'll use the development build till then..
I wanted to post the code snippet I came up with in case it helps someone else out:
FTP Script
  1. ##Test to see if local and remote file matches
  2. $REMOTESIZE1=GETFILESIZE(REMOTE,$file1)
  3. $LOCALSIZE1=GETFILESIZE(LOCAL,$file1)
  4.  
  5. IF ($LOCALSIZE1!=$REMOTESIZE1)
  6.     EXEC("del c:\ftp_temp\".$file1)
  7.     CLOSEHOST
  8.         GOTO :download_file1
  9.  
  10.  
Thanks forest.
Hello everybody! I am new in the forum. Just wanted to greet you :)