No Error Code if SFTP fails to Connect in Script

Advertisement

DaveR
Guest

No Error Code if SFTP fails to Connect in Script

Hi, I have a simple .cmd script that performs a check for presence of Files and if present calls winscp.com commandline with switches etc..
I have used the if %ERRORLEVEL% neq 0 goto error if a successful connection is used to then trigger a move of files after upload.
However, I had a situation where the SFTP client failed to connect to remote server. The logs showed an error level of 0 upon exit for failing to connect, which then triggered the move function.
Is this expected for a failed connection?

Please advise.
Thanks,
Dave

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
41,518
Location:
Prague, Czechia

Re: No Error Code if SFTP fails to Connect in Script

Please attach a full session log file showing the problem (using the latest version of WinSCP).

To generate the session log file, use /log=path_to_log_file command-line argument. Submit the log with your post as an attachment. Note that passwords and passphrases not stored in the log. You may want to remove other data you consider sensitive though, such as host names, IP addresses, account names or file names (unless they are relevant to the problem). If you do not want to post the log publicly, you can mark the attachment as private.

Reply with quote

DaveR
Guest

Re: No Error Code if SFTP fails to Connect in Script

Hi Martin,
Apologies for the delay in replying.
I have attached the log file showing a fail to connect and a successful session.
Have also included a copy of the script file.
Thanking you in advance.

Dave
Description: Log File & Script

Reply with quote

DaveR
Guest

Re: No Error Code if SFTP fails to Connect in Script

Hi Martin,

After a closer look at my script, I found that I had two syntax errors on the one line so the script worked if there was a successful connection.
After making the corrections, I changed the desitnation IP address to produce a connection timeout. WinSCP now produces the correct errorlevel 1 on a failed connection.

Sorry to have bugged you.

Regards,

Dave

Reply with quote

Advertisement

You can post new topics in this forum