Warning

 

Close
Confirm Action

Are you sure you wish to do this?

Cancel Confirm
AR15.COM
9/15/2008 10:59:50 AM EDT
Any scripting guru's around?

I'm trying to write a simple script that will do this...

I have a list of servers

server1
server2
server3

I want to pass those variables into the following command line

cscript sydi-server_short.vbs -t[servername] -ew -d -o"c:\[servername.xml]" -u[servername]\Administrator -pbiscuit

I have about 30 servers I want this to loop through. Is there an easy way in a DOS batch file to make server1,2,3, etc. a variable and pass it?
9/15/2008 11:09:45 AM EDT
[#1]
if you said something like

run.bat hello

then you bat file had
echo %1

the outcome would be
hello

so %1 %2 and %3 and so on are the arguments. not sure about a list and loop. looking it up...

-Foxxz
9/15/2008 11:12:48 AM EDT
[#2]
something like

FOR %? IN (%1 %2 %3 %4 %5 %6 %7 %8 %9) DO ECHO %?

would take up to 9 arguments and loop through.

-Foxxz
9/15/2008 11:15:11 AM EDT
[#3]
set sname=server1

if "%sname%" == "server1" @echo it worked

put % around the var in the command line to pass the value of the variable sname as server1
9/15/2008 11:15:55 AM EDT
[#4]
sounds like a good time for a "for loop" script
9/15/2008 11:29:24 AM EDT
[#5]
side track, maybe try windows scripting instead of dos.

http://msdn.microsoft.com/en-us/library/ms950396.aspx
9/15/2008 11:43:30 AM EDT
[#6]

Quoted:
something like

FOR %? IN (%1 %2 %3 %4 %5 %6 %7 %8 %9) DO ECHO %?

would take up to 9 arguments and loop through.

-Foxxz



for /F "tokens=1" %i in (list.txt) do cscript sydi-server_short.vbs -t[%i] -ew -d -o"c:\[%i.xml]" -u[%i]\Administrator -pbiscuit


and have in 'list.txt' the list of server names

-----list.txt----
SERVER1
SERVER2
SERVER3
.
.
.
SERVERn

---- EOF ----