Calling WinScp from SSIS task....

Advertisement

allgoldinc
Joined:
Posts:
1

Calling WinScp from SSIS task....

I am trying to retreive zip files from SFTP site. Manually it works fine nut in a code recently it stops working with an error: 2

[Execute Process Task] Error: In Executing "C:\Program Files (x86)\WinSCP\WinSCP.com" "" at "C:\Program Files (x86)\WinSCP\", The process exit code was "2" while the expected was "0".
--------------
Dim strReplace As String = Dts.Variables("strDestinationPath").Value.ToString
strReplace = Replace(strReplace, ".xml", ".zip")

' Run hidden WinSCP process
Dim winscp As Process = New Process()
winscp.StartInfo.FileName = "C:\Program Files (x86)\WinSCP\WinSCP.com "
'winscp.StartInfo.Arguments = "/log=" + logname
winscp.StartInfo.UseShellExecute = False
winscp.StartInfo.RedirectStandardInput = True
winscp.StartInfo.RedirectStandardOutput = True
winscp.StartInfo.CreateNoWindow = True
winscp.Start()

' Feed in the scripting commands
winscp.StandardInput.WriteLine("option batch on")

winscp.StandardInput.WriteLine("option confirm off")
winscp.StandardInput.WriteLine("PrivateKey=C:\ActiveJobs\SFTP Keys\Private Key.ppk")

winscp.StandardInput.WriteLine("open " + Dts.Variables("strSiteAddress").Value.ToString + "-hostkey = ""ssh-dss 1024 28:34:d7:cf:0e:82:a3:d0:d8:16:2a:b4:07:f3:b3:f1""")

winscp.StandardInput.WriteLine(" lcd " + Dts.Variables("strFileFolder").Value.ToString)
winscp.StandardInput.WriteLine(" get " + strReplace + " -nopermissions -nopreservetime ")
winscp.StandardInput.WriteLine(" rm *zip" + " -nopermissions -nopreservetime ")
winscp.StandardInput.WriteLine(" exit ")
winscp.StandardInput.Close()
' Collect all output (not used in this example)
Dim output As String = winscp.StandardOutput.ReadToEnd()
' Wait until WinSCP finishes
winscp.WaitForExit()
MsgBox(winscp.ExitCode)


Please, help me ....

Reply with quote

Advertisement

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

Re: Calling WinScp from SSIS task....

Difficult to help without seeing a log.

But this does not look correct definitelly:
winscp.StandardInput.WriteLine("open " + Dts.Variables("strSiteAddress").Value.ToString + "-hostkey = ""ssh-dss 1024 28:34:d7:cf:0e:82:a3:d0:d8:16:2a:b4:07:f3:b3:f1""")

Should be (space before -hostkey, no space before/after =):
winscp.StandardInput.WriteLine("open " + Dts.Variables("strSiteAddress").Value.ToString + " -hostkey=""ssh-dss 1024 28:34:d7:cf:0e:82:a3:d0:d8:16:2a:b4:07:f3:b3:f1""")

Reply with quote

Advertisement

You can post new topics in this forum