Forum Discussion
HKosova
Alumni
15 years agoHi Nassim,
Neither VBScript, nor Windows, nor TestComplete has built-in SFTP scripting functionality, so you'll need a third-party utility or scripting component for this purpose. WinSCP will do as you already use it. I see that WinSCP supports command-line automation, so you can automate downloading the file by passing appropriate commands to WinSCP from your VBScript code. Here's a rough example:
I hope this helps.
Neither VBScript, nor Windows, nor TestComplete has built-in SFTP scripting functionality, so you'll need a third-party utility or scripting component for this purpose. WinSCP will do as you already use it. I see that WinSCP supports command-line automation, so you can automate downloading the file by passing appropriate commands to WinSCP from your VBScript code. Here's a rough example:
Sub Test
Dim strWinSCP, strLogFile, oShell, oExec
strWinSCP = "C:\Program Files\WinSCP\winscp.com"
strLogFile = "C:\Test\winscplog.xml"
Set oShell = CreateObject("WScript.Shell")
Set oExec = oShell.Exec("""" & strWinSCP & """ /log=" & strLogFile)
' Feed commands to WinSCP
With oExec.StdIn
.WriteLine("option batch on")
.WriteLine("option confirm off")
.WriteLine("open session_URL_or_stored_session")
.WriteLine("get MyFile.csv C:\Test\")
.WriteLine("exit")
End With
' Wait until the WinSCP execution is completed
Do While oExec.Status = 0
Delay(100)
Loop
If oExec.ExitCode = 0 Then
Log.Message("File download completed successfully.")
Else
Call Log.Error("WinSCP exited with error code " & oExec.ExitCode & _
". See Additional Information for details.", _
aqFile.ReadWholeTextFile(strLogFile, aqFile.ctUTF8))
End If
End Sub
I hope this helps.