input 2 variables from 2 text files

May 19, 2010 at 08:22:47
Specs: Windows Server 2003
I need to input 2 variables from 2 text files into a batch file.
I know to pass one variable i.e.for /f %%a in (listcmp.txt) do (
but I don't know how to pass 2 variables from 2 text files. maybe something like...
for /f %%a in (text1.txt), %%b in (text2.txt) do (
Any help is appreciated
Thanks!

See More: input 2 variables from 2 text files

Report •

#1
May 19, 2010 at 08:38:57
A batch script can't access multiple files concurrently as usual in any programming language. You have to browse the files in sequence and, catch the variables then perform your processing in the main batch using the results.

Report •

#2
May 19, 2010 at 10:04:02
What's in the files?


=====================================
Helping others achieve escape felicity

M2


Report •

#3
May 19, 2010 at 10:35:35
Thanks for the replies.
I'm trying to run this script against multiple servers....

SC \\servername stop SMS_SITE_COMPONENT_MANAGER
SLEEP 3
SC \\servername stop SMS_EXECUTIVE
SLEEP 3
SqlCmd -E -S servername -d SMS_sitecode -i D:\SMS2003-SP3-KB974014-X86-ENU\update.sql -o D:\servername.txt
SLEEP 3
SC \\servername start SMS_SITE_COMPONENT_MANAGER
SLEEP 3
SC \\servername start SMS_EXECUTIVE
sleep 20

The variables are 'servername' and 'sitecode'
I need to run this on about 40 servers.
Any ideas?


Report •

Related Solutions

#4
May 19, 2010 at 14:01:07
this works, but not technically "concurrant". As IVO said, batch can't do that.
@echo off & setlocal enabledelayedexpansion
set /a sk=0
for /f "tokens=*" %%a in (d1.txt) do (
echo %%a
if !sk! equ 0 (set skip="tokens=*") else set skip="skip=!sk! tokens=*"
call :10 !sk!
set /a sk+=1
)
goto :eof

:10
for /f %skip% %%b in (d2.txt) do echo %%b & goto :eof
::------- end

if the data remains static, you might be better off to run this
batch as a "pre-formatter" to generate the interleaved data into
a temporary file then access that using the conventional method. The larger file#2 is, the slower the script will run.


Report •

Ask Question