Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

use variables from txt file?

Status
Not open for further replies.
Oct 15, 2002
153
US
I am trying to automate some simple commands to replicate some new folders to all of my identically configured servers.


is there a way to pull a list of variables from a txt file so that I can acheive the following:

mkdir \\[server1]\%path%$\%path%\%dir%
mkdir \\[server2]\%path%$\%path%\%dir%
mkdir \\[server3]\%path%$\%path%\%dir%
mkdir \\[server4]\%path%$\%path%\%dir%
...

the txt file would have the following
server1
server2
server3
server4
server5
...

I am trying to start with a list of the servers that I want to include, so that as servers are added and removed, I only have to change the txt file and the bat file above will follow along with no changes. This file is already used as a reference by other apps, so those changes are already done for other reasons.

I am already setting the variables (%dir%, etc)on the fly with user input each time the script is run, and I just need to pull the servernames from the txt file to complete the puzzle.

TIA
 
Ok, so which of these command do you know about?

OPEN,
INPUT (or LINE INPUT as needed),
CLOSE,
EOF, and possibly either
DO/LOOP or FOR/NEXT


Did you try using the HELP file(s)?

Also, what IDE are you using: QBasic? QuickBASIC? BATCH? or other??

What do you have already for code?
--MiggyD

--> It's a bird! It's a plane! No, it's an OS update patch! Ahh!! <--
 
I am at the "know enough to be dangerous" level of experience. I'm a network/OS guy, not a programmer by nature. to use the requisite car analogy; I can drive, build and fix the car pretty well, but I cant make a new part for said car.

The its a Batch file, and so far I have everything except the mechanism to get the info from my txt file full of server names into the batch file when it runs.

------------------

set /p drive=what drive do you want it on?:
set /p path=where on the drive do you want it?:
set /p dir=what is the name of the directory?:

mkdir \\server\%path%$\%path%\%dir%
mkdir \\server\%path%$\%path%\%dir%
.....
-----------------------

as you can see I can "variableize" (is that even a word?) everything except the server names I have stored. If I wanted to do a one-off I could by setting another path variable, but I dont feel like running this script 30x by hand each time I want to do it, or having to remember to add/remove the appropriate line of code that has to do with a server that has been added or removed since the last time it was run.

Thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top