Post a reply

Options
Add an Attachment

If you do not want to add an Attachment to your Post, please leave the Fields blank.

(maximum 10 MB; please compress large files; only common media, archive, text and programming file formats are allowed)

Options

Topic review

JAnderson

last post

Was from original poster
Guest

Possibly solved

Hey - thanks for the reply. Found some more information that may help and definitely explains why everything works when the batch file is invoked from the command prompt versus the windows task scheduler.

The task scheduler was reporting the job as a whole failed due to resource exhaustion (essentially out of memory).

However, the batch file did run and produce output with output from sftp_send_20130820.log as:

Job start 20130819 06:30 AM 

sFTP Binary error. See sFTP Log for details
Job Complete 20130819 06:30 AM


The "sFTP Binary error" message is generated when WinSCP returns a non-zero.

Double-checked write permissions for the "jobs" user. Can change write permissions to "everyone" without the behavior changing.

M: is a local volume on the server.

I suspect WinSCP is simply unable to start and there is no return code from WinSCP - the "if errorlevel" is picking up an error level from the shell/cmd interpreter, not WinSCP itself.

This seems a fairly obscure case, but I'm hoping it may help someone else to have it documented in the forums.
martin

Re: No xmllog produced with binary return code of 1

WinSCP should always produce some output. So it looks like it not run at all or there was a problem writing to the log. Try to add some logging to sftp_send_20130820.log before and after running WinSCP to see how long the execution lasted. And also to double-check the write permissions to the log file. Also chances are that the M: drive is not mapped/available for the scheduler's session.
JAnderson

No xmllog produced with binary return code of 1

Run Command:
"C:\Program Files\WinSCP\winscp.com" /script="m:\jobs\sftp_send_commands.txt" /xmllog="m:\jobs\sftp_send_xmllog.20130820.txt"


Running the command as-is from the command line always works and generates an xmllog file.

We are attempting to use the command is in a batch file that checks the errorlevel for a return code. When the return code from WinSCP is 0, an xmllog file is created every time. The batch file also redirects standard and error output to a general log file (see next code segment), separate from the xmllog file.

In the batch file, the run command is:
"C:\Program Files\WinSCP\winscp.com" /script="m:\jobs\sftp_send_commands.txt" /xmllog="m:\jobs\sftp_send_xmllog.20130820.txt" >> "m:\jobs\sftp_send_20130820.log" 2>&1


With the next line in the file the check for the return code/errorlevel.

sftp_send_xmllog.20130820.txt is the intended xmllog
sftp_send_20130820.log is the general job log

When the batch file is run manually, with command prompt run as domain user "jobs", everything works appropriately, including the generation of an xmllog file when the return code is zero or non-zero. Some winscp messages are sent to the general log file (via redirection)

When the batch file is run via the Windows task scheduler as domain user "jobs", the winscp binary is returning non-zero (caught by checking the errorlevel), not uploading any files, and no xmllog file is generated. There is also no output via the pipe to the general log file (via redirection).

WinSCP verison: 5.1.7 (build 3446)
OS version: Win2003 (fully patched)
"jobs" domain user has read/write access to m:\jobs and m:\upload directory trees.

Contents of sftp_send_commands.txt file (sensitive data stripped out)
option batch abort

option confirm off
open sftp://user:pass@9.9.9.9 -hostkey="ssh-rsa 1024 a9:a9:a9:a9:a9:a9:a9:a9:a9:a9:a9:a9:a9:a9:a9:a9"
put m:\upload\*.txt /
close
exit


Thank you in advance for your help