0

I have a Windows .bat file like this:

.....
echo Job start at %DATEANDTIME%  >> %Logfile%
ftp -s:ftpget.src >> %Logfile%
echo Job done at %DATEANDTIME%  >> %Logfile%

I can run this batch file on cmd console window and get the full log content. But when I schedule a task job to run it, I only can get "Job start" and "Job done" lines on log file. Are there any special settings need config?

Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992
studyzy
  • 13
  • 3

1 Answers1

0

I'd guess that you do not set a working directory of the scheduled job correctly, so the FTP script cannot be found using a relative "path" ftpget.src. Either make sure the working directory of the scheduled job is set to path, where the ftpget.src is stored. Or use an absolute path to the ftpget.src in the batch file.

When the ftp.exe cannot find the script, it prints an error on its error output. You do not redirect the error output, so you do not see it in the log file.

To redirect an error output to the same file, use 2>&1 after the >> %Logfile%:

ftp -s:ftpget.src >> %Logfile% 2>&1

For details, see:

Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992