1.

Solve : Importing password to batch script?

Answer»

I am a beginner - please be patient. I work for a small firm that UTILIZES about 100 batch files to pull data from a main database. Database requires a user name and password each time when CONNECTING via ftp. We have been listing the user name and password in the ftp script file and they work fine until we need to change the password again. Then it is a tedious task to open all 100 files and change the password. Is there a way that the batch file can look up or import a password from one location thus eliminating the need to open all the batch files when the password changes? Thanks in advance for your help!Are you saying that you have multiple FTPs and each has a different log-in name/pass?Multiple FTPs pulling different data but with the same user name and password..I don't know if batch can be set to automatically change like that but you may be able to have a batch log into all of the FTPs and change the the batch their. I don't know if that is actually possible but I am shour someone knows if it is, and how to do it, if it is. Was that confusing?If you dont mind the password being held in clear text, store it in a 1 line file (call it password.txt) then have this line
Set /P password=which reads the first line from the file and puts it in the environment variable %password%
you then refer to %password% in your batchfile
Ok but were would you keep the password.txt file? If its right NEXT to the batch file then he would still have to update every single one. If it is in one location for all of the batch files to read then what is the code to make it read from the remote location.Thought it would be helpful to show an example of what we are working with.. Batch files are LOCATED in many locations but would like to draw the password from just one..

Example.bat
ftp -s:"C:\Hold\TestHold.txt" gsystcp1.sys.narley.com

TestHold.txt
DB101
Password
get 'Test.xDB101.PulledData.txt' "C:\wlldb2101\Info\PulledData.txt"
Quitwell, drawing from gpl's idea; would it be possible to setup a network share- (or use an existing network share) and place the file "testhold.txt" there?This seems like a similar idea. Maby you could build off of that.gpl - Thanks for your response-Its beginning to make some sinse to me. I'm still not sure where to plug in the set /p Password=GrahamExample posted earlier with disguised info....Whoops, missed it

Try something like this
Code: [Select]Example.bat
-----------
@Set /P Password=<C:\Hold\pw.txt
> C:\Hold\cmds.ftp echo DB101
>> C:\Hold\cmds.ftp echo %Password%
>> C:\Hold\cmds.ftp echo get 'Test.xDB101.PulledData.txt' "C:\wlldb2101\Info\PulledData.txt"
>> C:\Hold\cmds.ftp echo Quit

ftp -s:"C:\Hold\cmds.ftp" gsystcp1.sys.narley.com
Code: [Select]pw.txt
------
MyPasswordIsSecret
gpl - You NAILED it! Works perfectly! Thanks......



Discussion

No Comment Found