Problem passing/reading argument in Script file

Advertisement

Arun
Guest

Problem passing/reading argument in Script file

Hi,
I have started using winscp for ftping file to a secure ftp site. since we have lots of files to ftped to diff ftp server in future , i wrote a script file which will accept argument passed in command line..

Here is the script :

---------------------------------- SFTP_Script.txt
option batch on
option confirm off
open %1% -hostkey=%2%
put %3%
exit
----------------------------------

My command line is like this :

winscp.com /script=SFTP_Script.txt /parameter "sftp://{username}:{passwd}@{servername}" /parameter "ssh-rsa 1024 xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx" /parameter ":\data\test_sftp.txt"


When i run this command line , i get the error message :

----------------------------------error msg
Searching for host...
Host does not exist
batch on
confirm off
Searching for host...
Connecting to host...
Authenticating...
Using username "ftp_rptsvcs".
Authenticating with pre-entered password.
Authenticated.
Starting the session...
Reading remote directory...
Session started.
Active session: [1] ftp_rptsvcs@10.254.4.170
File or folder '%3' does not exist.
System Error. Code: 2.
The system cannot find the file specified
(A)bort, (R)etry, (S)kip, Ski(p) all: Abort
-----------------------------------


Not sure what the reason for the error is. can anyone please help me on this





PS :

But when i run the following script from command line , where i do have only 2 arguments , it runs perfectly.

-------------------------------SFTP_Script_old.txt
option batch on
option confirm off
open %1% -hostkey=%2%
put c:\data\test_sftp.txt
exit
-------------------------------

Reply with quote

Advertisement

Arun
Guest

small correction to my post. my command line is like this :

winscp.com /script=SFTP_Script.txt /parameter "sftp://{username}:{passwd}@{servername}" /parameter "ssh-rsa 1024 xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx" /parameter "c:\data\test_sftp.txt"


corrected stated the 3rd argument.


Thanks,
Arun

Reply with quote

Arun
Guest

Thanks for your reply. I tried as u said :


winscp.com /script=SFTP_Script.txt /parameter "sftp://{username}:{passwd}@{servername}" "ssh-rsa 1024 xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx" "c:\data\test_sftp.txt"

If i run the above command line , i get the following error msg.
--------------------------------------------------------------------
batch on
confirm off
Too many parameters for command 'open'.
No session.
--------------------------------------------------------------------

we should put /parameter for each argument we pass?

Reply with quote

Advertisement

You can post new topics in this forum