I am trying to write a WinSCP script. I tried the example at,
https://winscp.net/eng/docs/guide_automation#parametrized
but the parameter value is not taken by the script.
When the script is invoked as,
winscp.com /script=testscript /parameter param1
The following occurs:
First,
Searching for host
host not found
is displayed.
Followed by, actually connecting to the host using the
"open command"
but the parameter is never substituted.
It still displays as %1
I don't know which example you are talking about but I will show you some sample code that I have. I hope it helps. This code is all located in a .bat file.
In this example, a variable %folder% is made with the name of today's date in the format of 2/28/2012. I then ask the user for their username and it gets saved in the variable %username%, same with %password%. I then used the %folder% variable to make a directory with a folder named %folder%.
Now we dive into actual 'WinSCP Code'.
I then located the path towards my WinSCP.exe and then called console. After console was called, I connected to my WinSCP server using the 'open' command and the %Username% and %Password% variables.
@ECHO OFF
cls
set folder=%date:~4,2%-%date:~7,2%-%date:~10,4%
SET /P username="Enter Username: "
IF "%username%"=="" GOTO Error
SET /P password="Enter Password: "
rem -- Clear Screen to hide password
cls
IF "%password%"=="" GOTO Error
md C:\Logs\%folder%\int-rpt01\
"C:\""Program Files""\WinSCP\WinSCP.exe" /console /command "option batch abort"
"option confirm off" "open sftp://%username%:%password%@server.server.net:22"
"get /opt/ibm/cognos/c10_64/logs/cogserver.* C:\CogServerLogs\%folder%\int-rpt01\" "exit"
I hope this helps. Any more information on which example you are using and or how you are using it would be appreciated.