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

Clem

Great, it's exactly what I was looking for!

Yes, I know, for hostkey

Thank you!
martin

Re: Get return code of "call"

WinSCP returns exit code 1 (by default), when the command returns exit code >= 2. You can make WinSCP return 1 even if the command returns 1, by setting ExitCode1IsError raw session setting:
open scp://root:strongPassword@1.2.3.4 -hostkey=* -rawsetting ExitCode1IsError=1

But you cannot make WinSCP return the actual exit code of the command.
WinSCP is not the right tool for automating remote shell command execution.
Use Plink instead.

Btw, combination of "strongPassword" and -hostkey=* is just wrong. You are possibly sending your "strong password" right to the hands of an attacker.
Clem

Get return code of "call"

Hi,

I'm using WinSCP.com and I'm trying to get the return code of commands called with call
Basically, I launch the following command
WinSCP.com /script=./script.txt /parameter 'foo' 'bar'

With the script file which looks like
open scp://root:strongPassword@1.2.3.4 -hostkey=*
call /root/myRemoteScript.sh %1% %2%
close
exit

But even if /root/myRemoteScript.sh %1% %2% returns 1, WinSCP.com returns 0. I grabbed the return code of WinSCP.com with %ERRORLEVEL%

How can I do that?

Thank you!