Capturing Return Code

Advertisement

JonWayn
Joined:
Posts:
3
Location:
Bellingham, WA

Capturing Return Code

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]

Reply with quote

Advertisement

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

Re: Capturing Return Code

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.

Reply with quote

JonWayn

About omitted quotes

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?

Reply with quote

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

Re: About omitted quotes

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.

winscp.com /command ...
echo %errorlevel% > exitcodefile

Reply with quote

Advertisement

You can post new topics in this forum