Topic "Problem passing/reading argument in Script file"

Author Message
Arun

Guest


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
-------------------------------
Advertisements
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
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 25015
Location: Prague, Czechia
Use the /parameter switch only once.
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?
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 25015
Location: Prague, Czechia
Put double quotes around parameter references, particularly around %2%.
Advertisements

You can post new topics in this forum






Search Site

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!

Donate

About donations

$9   $19   $49   $99

About donations

Recommend

WinSCP Privacy Policy

WinSCP License