Topic "Script that prompts for password and then uses as variable"

Author Message
campbjj
[View user's profile]

Joined: 2009-02-10
Posts: 3
Following the great examples here, I have created a DOS batch file that can connect to one server, download files, disconnect from that server, reconnect to another server, downloads files, etc... In total I do the same thing to about 6 servers. This scripting is a huge advantage to me and makes me a little more productive. The initial call is scripted like this (test_call.bat):

Code:

for /f %%i in ('realdate.com /d') do (set DT=%%i)
   md c:\LOGFILES\%DT%
   "C:\Program Files\WinSCP\WinSCP.exe" /console /script="C:\auto_ftp.txt"



For each of the servers that I am connecting to and downloading the files for, I use the same username and password. So, yes, in the solution as it stands now I must type in the password each time the script changes servers. See something close to C:\auto_ftp.txt below.

Code:

open user@exampleserver1
get /logfiles/logfile.log c:/logfiles/%DT%/exampleserver1.logfile.log
close
open user@exampleserver2
get /logfiles/logfile.log c:/logfiles/%DT%/exampleserver2.logfile.log
close
open user@exampleserver3
get /logfiles/logfile.log c:/logfiles/%DT%/exampleserver3.logfile.log
close


And so forth. For security reasons, I do not want to put the password into the C:\auto_ftp.txt file. Is there a way to have test_call.bat prompt me for the password, store that as a variable, and then C:\auto_ftp.txt can use the variable for the password?

Thanks for your time.
campbjj
[View user's profile]

Joined: 2009-02-10
Posts: 3
Okay, I tried something, and it is giving me some good results, but I'm not quite where I want to be yet. I modified my calling script like so:
Code:

@echo off
for /f %%i in ('realdate.com /d') do (set DT=%%i)
   md c:\LOGFILES\%DT%
   set /p input=Type password:
   "C:\Program Files\WinSCP\WinSCP.exe" /console /script="C:\auto_ftp.txt"

And then, in C:\auto_ftp.txt I changed all the logins to use the following
Code:
user:%input%@exampleserver1


However, the issue that I have is that this password is being typed in clear text when the user enters it. Is there another way of doing this, or of a way to have the window mask the typing?

Thanks.
campbjj
[View user's profile]

Joined: 2009-02-10
Posts: 3
I apologize, but I've fixed my script after reading this URL:
http://windowsitpro.com/scripting/scripting-password-prompts
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