I am trying to write a batch file that has to do the following:
1) run a command that has some output.
2) check if the output contains some text
3) if yes - do something
What I tryed to do is to save the output to a file and then save the data from file to variable:
[command] > c:\temp.txt
set /p RetVal= < c:\temp.txt
del temp.txt
But it doesn't work well.
Anybody has some ideas how to do all these?
Thanks a lot!
Check if command's output contains some text
Moderator: DosItHelp
Re: Check if command's output contains some text
You should tell us which command it is and if you try to process a Standard-Msg. or an Error-Msg.
Regards
aGerman
Regards
aGerman
-
- Expert
- Posts: 391
- Joined: 19 Mar 2009 08:47
- Location: Iowa
Re: Check if command's output contains some text
Code: Select all
yourcommandhere | find /i "the text you're looking for"
if not errorlevel 1 (
echo The stuff you want to do
echo goes here
)
Re: Check if command's output contains some text
avery_larry wrote:Code: Select all
yourcommandhere | find /i "the text you're looking for"
if not errorlevel 1 (
echo The stuff you want to do
echo goes here
)
Thank you !! this works for me