Can't communicate with WinSCP Shell from script
I have encountered a new problem since installing Beta version 5.0.2 and 5.0.3.
I need to use passive mode and explicit ssl with a California government agency. I was able to do that with our previous version of WinSCP using a stored session, but I don't believe it was supported in a script until 5.0.2.
Now that we have installed 5.0.2 (and subsequently, 5.0.3), I can open the Winscp window with the following code:
WshShell = CREATEOBJECT("WScript.Shell")
WshShell.CurrentDirectory = this.icTempDirectory
ON ERROR llSuccess = .F.
oExec = WshShell.EXEC('"' + this.icWinSCPPath + '" /log=putlog.xml')
When I try to send my script to Winscp, I get no response.
I use the following to send the script:
oExec.StdIn.WriteLine('option batch abort')
oExec.StdIn.WriteLine('option confirm off')
IF (.inReconnectTime > 0)
oExec.StdIn.WriteLine('option reconnecttime ' + ALLTRIM(STR(this.inReconnectTime)))
ENDIF
oExec.StdIn.WriteLine('open ftps://' + .icUsername + ':' + .icPassword + '@' + .icServer + lcPort + '-explicitssl -passive=on -timeout=600')
oExec.StdIn.WriteLine('get /users/apprisk/ak1/*.txt ' + lcTempDirectory)
oExec.StdIn.WriteLine('close ')
oExec.StdIn.WriteLine('exit ')
The WinSCP window doesn't close, and the application stops.
When I manually close the window and execute the following:
lcOutput = oExec.StdOut.ReadAll()
All that is returned is the "winscp>" prompt.
What has changed that is causing my problem? I have tried to use the stored sessions that were working previously, but they no longer work either.
I need to use passive mode and explicit ssl with a California government agency. I was able to do that with our previous version of WinSCP using a stored session, but I don't believe it was supported in a script until 5.0.2.
Now that we have installed 5.0.2 (and subsequently, 5.0.3), I can open the Winscp window with the following code:
WshShell = CREATEOBJECT("WScript.Shell")
WshShell.CurrentDirectory = this.icTempDirectory
ON ERROR llSuccess = .F.
oExec = WshShell.EXEC('"' + this.icWinSCPPath + '" /log=putlog.xml')
When I try to send my script to Winscp, I get no response.
I use the following to send the script:
oExec.StdIn.WriteLine('option batch abort')
oExec.StdIn.WriteLine('option confirm off')
IF (.inReconnectTime > 0)
oExec.StdIn.WriteLine('option reconnecttime ' + ALLTRIM(STR(this.inReconnectTime)))
ENDIF
oExec.StdIn.WriteLine('open ftps://' + .icUsername + ':' + .icPassword + '@' + .icServer + lcPort + '-explicitssl -passive=on -timeout=600')
oExec.StdIn.WriteLine('get /users/apprisk/ak1/*.txt ' + lcTempDirectory)
oExec.StdIn.WriteLine('close ')
oExec.StdIn.WriteLine('exit ')
The WinSCP window doesn't close, and the application stops.
When I manually close the window and execute the following:
lcOutput = oExec.StdOut.ReadAll()
All that is returned is the "winscp>" prompt.
What has changed that is causing my problem? I have tried to use the stored sessions that were working previously, but they no longer work either.