Reputation: 991
I am using (or trying to) WinSCP to communicate with a public SFTP server for downloading different data. The perfect scenario would be that I download the most recent file from the SFTP using SSIS but I cannot get the example from winscp.net which uses WindowsPowershell to run.
So another solution would be to run a simple script which downloads all zip files. Here is what I have and this works alone when executed (.bat
file):
winscp.exe /console /command "option batch abort" "option confirm off" "open sftp://[email protected]" "get *.zip c:\" "exit"
When I try to do the same in SSIS within the Execute Process Task, it fails with the very informative error:
The process exit code was "1" while the expected was "0"
I've tried everything (I guess) from WinSCP.net documentation but nothing worked. Also specified the hostkey in the open
command but same failure.
Here is a screenshot of the Execute Process task Editor:
Upvotes: 2
Views: 12554
Reputation: 202272
You are trying to make WinSCP run a Windows batch file. It actually means that you are asking WinSCP to run WinSCP. That obviously fails. You'd see that yourself, had you tried to execute the command you are asking SSIS to run:
"C:\Program Files (x86)\WinSCP\WinSCP.exe" "/script=C:\Program Files (x86)\WinSCP\Script1.bat"
This probably outputs something like:
Unknown command 'winscp.exe'
You need to move the WinSCP arguments from Script1.bat
into SSIS Arguments parameter:
/console /command "option batch abort" "option confirm off" "open sftp://[email protected]" "get *.zip c:\" "exit"
Or make your Script1.bat
(you should change an extension then) contain WinSCP commands:
option batch abort
option confirm off
open sftp://[email protected]
get *.zip c:\
exit
For a general discussion of the topic, see:
Upvotes: 2