Reputation: 45
I would like to ask if how can I find strings (3 or 5 words) on the text file with conditions. If the strings was found then a certain variable will become equal to 1.
Scenario
I have a batch file will run every 12:01 AM. This batch file have multiple commands inside. Please see below:
Tail logger - This was the first function will run on the batch file. It will tail log the server and put the logs on a server.log and create another log file that will have the last 2 lines of the logs (temp.log)
Log Checker - After the tail logger, This function will run and will find the a certain words on the temp.log.
Example:
This will find a strings "The task complete" if the checker find this it will make a variable from set X=0 to set X=1.
Thanks.
Upvotes: 0
Views: 1829
Reputation: 80213
findstr /?
from the prompt will guide you.
`findstr /L /c:"The task complete" "logfilename" >nul
will set errorlevel
to 0 if found 1 otherwise (strictly not-0 otherwise, as "filemissing" produces errorlevel=2, I believe)
Upvotes: 1