Post a reply

Before posting, please read how to report bug or request support effectively.

Bug reports without an attached log file are usually useless.

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

martin

WinSCP does exit with code 1 when the connection fails. I'm not sure what you ask for.
Amar

Hi ,

I want to return errorlevel 1 in case of Network Error : Connection TImed out ..I am using below code..can you please suggested how can I do that.

# Automatically answer all prompts negatively not to stall
# the script on errors
option batch on
# Disable overwrite confirmations that conflict with the previous
option confirm off
option Ignore permission errors on

setlocal capturenetworkerror
open sftp://root:xyz@radio-user
option transfer binary
option batch abort
cd prod/orders
option batch continue
lcd E:\localserver\shared\Targetfiles\
put *Myfiles_*.xml
exit
close
Aviator Sheep

Re: SFTP log of WinSCP/MOVEit session not returning error codes

Aviator Sheep wrote:

martin wrote:

See https://winscp.net/eng/docs/scriptcommand_get

When wildcard is used, command succeeds, without doing anything, if the wildcard does not match any file, by default (you can change this using option failonnomatch on command).


(You have to use the latest beta version for this)


Wow! I would never have thought to review the get command for this. I should never overlook the rest of the script. I feel silly it was that easy :) Thank you for the help, I really appreciate it.


It's working perfectly. Thank you, again! =)
Aviator Sheep

Re: SFTP log of WinSCP/MOVEit session not returning error codes

martin wrote:

See https://winscp.net/eng/docs/scriptcommand_get

When wildcard is used, command succeeds, without doing anything, if the wildcard does not match any file, by default (you can change this using option failonnomatch on command).


(You have to use the latest beta version for this)


Wow! I would never have thought to review the get command for this. I should never overlook the rest of the script. I feel silly it was that easy :) Thank you for the help, I really appreciate it.
martin

Re: SFTP log of WinSCP/MOVEit session not returning error codes

See https://winscp.net/eng/docs/scriptcommand_get

When wildcard is used, command succeeds, without doing anything, if the wildcard does not match any file, by default (you can change this using option failonnomatch on command).


(You have to use the latest beta version for this)
Aviator Sheep

SFTP log of WinSCP/MOVEit session not returning error codes

Using a batch file, I call a WinSCP script. The process is fully functional and, if files are available, will execute perfectly. However, if no files are present, no error code or warning code is being generated that I can tell. The calling batch file sends emails to a team based on whether or not a file was present and this is hampering that functionality. For various reasons, I can only check for a download from the log file. In my FTP experience, there is always a clearly indicated error, or at least warning - ex. 'File not found'. This is not the case in the SFTP log.

I am connecting to Ipswitch's MOVEit when a batch file calls WinSCP.com, uses a local .ini, and a small script. The WinSCP Version is 5.5.4 running on Win7 Enterprise, SP1. I have included the text of the calling file and the WinSCP script below, tho I omitted parts of the batch file that were not relevant.

I have been searching the net, Stack Overflow, the WinSCP support pages, and other resources and it appears I should be getting a plain text response or at least an error code or warning code returned. The closest thing I can find is "status code" or "special code" in the log file but neither of these seem to correspond to no files found. A log level 1 is attached with sensitive info changed to generic. I also included a copy of the XML log.

Am I missing something completely? Is the remote server not configured to send me this information? Is there just no error of this type to be returned? It works perfectly, every time, but no recorded log entries if files don't exist.

Calling line from batch:
START /WAIT WinSCP.com /console /script=WSCP-GetRDC.txt /log=%log% /xmllog=%log2%


WinSCP Script:
option batch on

option confirm off
open sftp://USER/PASS/HOST -hostkey="KEY HERE" -timeout=60 -passive=on
option transfer binary
get -delete *.ext1 "\\MyPath\Folder\"
get -delete *.ext2 "\\MyPath\MyFolder"
exit


Thank you!