Topic "Pass 2 parameters to WinSCP"

Author Message


I need to run winscp as a process task from SSIS passing in the sftp server connection details and the file to send. I am trying to run this from a command prompt before integrating with SSIS.
To start with I am passing 1 parameter, so I have a batch file (X1A) that contains the line
winscp /command "option batch on" "option confirm off" "open sftp://user:password@server:22" "put %1%" "exit"
Then from command prompt I enter the command x1a file.txt
And it sends the file with no trouble
If I changed the batch file to replace the connection information with %1% and the %1% with %2" so I get this
winscp /command "option batch on" "option confirm off" "open %1%" "put %2%" "exit"
then ran the command x1a "sftp://user:password@server:22" "file.txt"
The command fails and displays
winscp /command "option batch on" "option confirm off" "open "sftp://user:password@server:22"2" "exit"
How do I pass 2 paramaters to winscp?
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 26858
Location: Prague, Czechia
You have probably takes the %1% syntax from the description of the WinSCP script syntax. But note that in your case, you are passing the %1% on the command-line, not in the script. In this case it is resolved by the Windows shell, which has syntax %1 only. So you end up with %1 references to the first parameter of the .bat file, and %" "put % reference to non-existing (and invalid) environment variable. So change %1% to %1. Though you still have a problems with quoting. If there are no spaces in the value of %1, avoid using quotes when running the .bat file.
Martin Prikryl

You can post new topics in this forum


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!


About donations

$9   $19   $49   $99

About donations


WinSCP Privacy Policy

WinSCP License