Script that prompts for password and then uses as variable
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 (
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
And so forth. For security reasons, I do not want to put the password into the
Thanks for your time.
test_call.bat
):
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.
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
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.