0

I wrote some scripts which ftp files from a server to the local machine. The scripts have different behaviour under difference mode.

If I run it interactively, the ftp is fine:

ftp> mget *abc*.reviewed
200 Type set to A.
200 PORT command successful.
150 Opening ASCII mode data connection for xxx_abc_yyyymmdd.reviewed(506 bytes).
226 Transfer complete.
ftp: 506 bytes received in 0.00Seconds 506000.00Kbytes/sec.

If I scheduled it in the windows task scheduler, it only show the following:

ftp> mget *abc*.reviewed
200 Type set to A.

I suspect there is a error following but there are not log. What could I done wrong?

Sample of my code:

call :Logic > E:\ftp_%yyyymmdd%.log 2>&1 
exit /b 0
:Logic
ftp -i -s:C:\App\XXX\bin\ftp_script.txt some.host.net 

I make the output into a log file but I don't know if the error stream has been successfully configure. I could be losing some error log.

content of ftp_script.txt:

username
password
lcd E:\YYY
cd /XXX/YYY/ZZZ
mget *abc*.reviewed
mget *bcd*.reviewed
mget *cde*.reviewed
bye

Further case study:

The script was scheduled to be run at everyday 8PM. I checked the server today and found out the target server contains the files I want, with the last modifed attribute of 6:54PM. So the file should be there at 8PM and they were not ftp in yesterday's schedule.

I assume the last modified attribute equal to the time it was copied ( from other directory ) or rename ( the file should be renamed from .csv to .reviewed ).

I scheduled a one off task in 12:40pm to run the script and the files were successfully ftp from the target server to the local server.

It is really confusing.

lamwaiman1988
  • 3,729
  • 15
  • 55
  • 87

1 Answers1

0

It might be a problem with the firewall rejecting connection in active FTP mode, you might try setting passive mode issuing a PASV command (QUOTE PASV with Windows ftp.exe) and see if this fixes the problem (more details about the two different modes here) .
I also suggest that you set debug so that you get the details from the server (add DEBUG command).
If you are not transferring text, remember to include a BINARY command, too.

eddo
  • 2,094
  • 1
  • 25
  • 31
  • you can try with **QUOTE PASV** if it is windows ftp.exe – eddo May 16 '12 at 04:33
  • did you try issuing DEBUG and redirecting the output to a text file to verify what are the details of the session? It might help to diagnose. – eddo May 16 '12 at 04:37
  • Please check the EDIT and see if there are any hint. – lamwaiman1988 May 16 '12 at 05:14
  • why don't you try to simplify debug and see if the files are being downloaded using the script (redirect the output to an empty folder so that you have no doubts), secondly to launch the same script from the scheduler (and if there is a change in the result that might depend on the credentials under which the task is launched) – eddo May 16 '12 at 05:35