Topic "Capturing Return Code"

Author Message
JonWayn
[View user's profile]

Joined: 2012-06-22
Posts: 3
Location: Bellingham, WA
I just installed WinSCP - awesome program I must add. I use Visual Basic to upload a file on a regular basis.

Shell """C:\Program Files (x86)\WinSCP\WinScp.exe"" /command ""option batch abort"" ""open abc.com"" ""put """"c:\A\Nu File.ttt"""" ""exit"""

When I run the above statement and then open the site in explorer, the file gets uploaded but with the name 'exit'. If I remove the exit switch all together, then the file gets posted correctly. What am I doing wrong here? I dont seem to lose any functionality by omitting the exit switch but I'd just like to know how to include it

Also, how can I capture return codes? Do I have to specify another file that receives the return code? If so, how?[/code]
Advertisements
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 25015
Location: Prague, Czechia
It looks lyou are missing two double-quoted after put filename argument. Should be:
Shell """C:\Program Files (x86)\WinSCP\WinScp.exe"" /command ""option batch abort"" ""open abc.com"" ""put """"c:\A\Nu File.ttt"""""" ""exit"""

I do not know Visual Basic, so I do not know how do you capture exit code. Anyway, I suggest you use winscp.com for that, not winscp.exe.
_________________
Martin Prikryl
JonWayn
[View user's profile]

Joined: 2012-06-22
Posts: 3
Location: Bellingham, WA
You're absolutely right, prikryl, those would be the closing quotes for the ""put"" switch. That would explain why the Exit switch was seen as a part of the Put switch. Thanks. The last question was language independent though: How do you pipe return codes to a file?
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 25015
Location: Prague, Czechia
Storing exit code to a file is task external to WinSCP. So it is language dependant.
If you do not know how to do that in VB (there has to be a way), you can create a .bat file like below and execute it from VB instead of executing winscp directly.

Code:
winscp.com /command ...
echo %errorlevel% > exitcodefile
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