Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm scripting WinSCP, and need to dynamically pass in a FTP username and password, depending on which environment I'm using.

However, the docs say, "WinSCP does not support providing the passphase from command line or by other means allowing automation"

Is there another way?

share|improve this question
    
One thing to be aware of (if you weren't already) is that the username and password will be stored in plain text. If there's a console log (or something like doskey is running), it may be possible for someone to retrieve these passwords. –  Andrew M. Dec 7 '11 at 23:10
    
@Redmumba, correct. The password would be exposed to a local attacker, or local malicious code with sufficient privileges. However, there are mitigating factors in our case to prevent escalation. Further, FTP passwords are already vulnerable to network interception. –  Matthew Flaschen Dec 8 '11 at 0:09
add comment

3 Answers

Have you tried using something like ftp://user:pass@ftp.example.com as the address ?

You script can then build this uri depending on you environment.

This example uses sftp but ftp should be similar.

share|improve this answer
add comment

The following is what worked for me

created a file called script.text. Following is the content of script.txt

open ftp://uname:pwd@ftpserver_url

then from the command prompt executed the following statement

c:\ "path_to_winscp\WinSCP.exe" /console /script=c:/script.txt
share|improve this answer
    
Note that I asked about passing it in, whereas you're embedding it in the script. –  Matthew Flaschen Jan 25 '13 at 5:40
add comment

Use /parameter and %1% and %2% in the script:

WinSCP.com /console /parameter username password /script=some.script

In some.script:

open ftp://%1%:%2%@servername
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.