Help needed with using resuts from another command

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
Avaya-geek
Posts: 2
Joined: 28 Aug 2008 05:13

Help needed with using resuts from another command

#1 Post by Avaya-geek » 28 Aug 2008 05:36

Hi all,

New here so go easy on me..

I am writing a batch file to automate some cumbersome commands. The long and short of what i am tring to do is that i can get a command to run and it puts its out put into a tmp file, i then echo the results.

echo | capExtract c:\capextract %filename% > tmpcapextract$$.$$$
find "Found channel " < tmpcapextract$$.$$$
find "Found module " < tmpcapextract$$.$$$
del tmpcapextract$$.$$$

it gives the following output:

Found channel 6
Found module 1

Now what i would like to do is to use the numbers in the output as they will vary depending on what file a choose to use, but i would like to use them in my batch job later.

For example now that the file was checked and it returned with channel 6 and module 1. I now want to run another command capExtract c:\capextract %filename% ref %ChannelID% %moduleID%

digit 6 would need to be in %ChannelID%
digit 1 would need to be in %moduleID%

I hope this makes sense. Any help greatly received.

DosItHelp
Expert
Posts: 239
Joined: 18 Feb 2006 19:54

#2 Post by DosItHelp » 28 Aug 2008 20:43

Avaya-geek,

Try this:

Code: Select all

for /f "tokens=3" %%A in ('find "Found channel " < tmpcapextract$$.$$$') do set "ChannelID=%%A"
for /f "tokens=3" %%A in ('find "Found module " < tmpcapextract$$.$$$') do set "moduleID=%%A"

DosItHelp? :wink:

Avaya-geek
Posts: 2
Joined: 28 Aug 2008 05:13

#3 Post by Avaya-geek » 29 Aug 2008 07:07

Hey thanks a ton for this, it didnt quite work as i got a message saying "< was not expexted at this time". I removed the < and bingo, you are a genius... :D

Now i have 1 more question, as something i was not expecting just happened. When i just got my batch to look at another test file it found the following:

Found channel 6
Found channel 38
Found module 1

So now it would seem that i need to ask the user only if there is more than one channel ID, any ideas?



DosItHelp wrote:Avaya-geek,

Try this:

Code: Select all

for /f "tokens=3" %%A in ('find "Found channel " < tmpcapextract$$.$$$') do set "ChannelID=%%A"
for /f "tokens=3" %%A in ('find "Found module " < tmpcapextract$$.$$$') do set "moduleID=%%A"

DosItHelp? :wink:

Post Reply