Pass 2 parameters to WinSCP

Advertisement

sotn100
Guest

Pass 2 parameters to WinSCP

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?

Reply with quote

Advertisement

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

Re: Pass 2 parameters to WinSCP

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.

Reply with quote

Advertisement

You can post new topics in this forum