Topic "Calling WinScp from SSIS task...."

Author Message
allgoldinc
[View user's profile]

Joined: 2012-01-31
Posts: 1
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 ....
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 25034
Location: Prague, Czechia
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""")
_________________
Martin Prikryl
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