Computing.Net > Forums > Programming > Dos findstr help required

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Dos findstr help required

Reply to Message Icon

Name: jan (by janita)
Date: June 11, 2008 at 02:57:13 Pacific
OS:
CPU/Ram: 512
Product: Vectra 400
Comment:

Hi,

I have a batch program which does some functionality and writes a log file. This log file will also contain errors if any. But the program always ends with an error level of 0.

I have added the following line
findstr /c:Error "%BXT_LOG_FILE%"
to find any lines with the word error. This is working fine and my sysout shows perfectly all error messages.

Now I want a condition to check if findstr returned error messages then set errorlevel as 1 else 0 and write this errorlevel to the same log file

how can i do this?

Regards,
Jan



Sponsored Link
Ads by Google

Response Number 1
Name: klint
Date: June 11, 2008 at 04:05:16 Pacific
Reply:

DOS doesn't have findstr, so I presume you meant to say XP. Findstr returns 1 when it cannot find the string, and 0 when it does. This is the reverse of what you're asking, so you could do this:

if errorlevel 1 (
echo No errors!
)
else (
echo Some errors were present.
)

If you really want to reverse the errorlevels:

if errorlevel 1 (cmd /c exit 0) else (cmd /c exit 1)


0
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Dos findstr help required

help with question www.computing.net/answers/programming/help-with-question/8317.html

ColdFusion help required www.computing.net/answers/programming/coldfusion-help-required/8952.html

Dos: set help??????? www.computing.net/answers/programming/dos-set-help/11510.html