Topic "SFTP log of WinSCP/MOVEit session not returning error codes"

Author Message
Aviator Sheep

Guest


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:
Code:
START /WAIT WinSCP.com /console /script=WSCP-GetRDC.txt /log=%log% /xmllog=%log2%


WinSCP Script:
Code:
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!
RDCWSCPLog_XML.log (168 Bytes) Private file

Description: WinSCP to MOVEit XML log of connection with no files available.

RDCWSCPLogFORDEBUG.txt (12.53 KB) Private file

Description: WinSCP to MOVEit plain text log of connection with no files available.

Advertisements
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24993
Location: Prague, Czechia
See https://winscp.net/eng/docs/scriptcommand_get

Quote:
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

Guest


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

Quote:
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 Smile Thank you for the help, I really appreciate it.
Aviator Sheep

Guest


Aviator Sheep wrote:
prikryl wrote:
See https://winscp.net/eng/docs/scriptcommand_get

Quote:
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 Smile Thank you for the help, I really appreciate it.


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

Guest


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
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24993
Location: Prague, Czechia
WinSCP does exit with code 1 when the connection fails. I'm not sure what you ask for.
Advertisements

You can post new topics in this forum






Search Site

What is WinSCP?

It is award-winning SFTP client, SCP client, FTPS client and FTP client integrated into one software program for file transfer to FTP server or secure SFTP server. [More]

And it's free!

Donate

About donations

$9   $19   $49   $99

About donations

Recommend

WinSCP Privacy Policy

WinSCP License