Hi DOS gurus, im a DOS noob. I want to create a DOS script that will read a log/text file. Below is the requirement:
The script will basically search for a word/string(let say "ERROR:XXXX") from the log file, if the exact word/string is found, then the script will restart a windows services.
log file name = logs.txt
file to search from the logs = ERROR:XXXX
Thanks in advance.
dos command to read a text file
Moderator: DosItHelp
Re: dos command to read a text file
Code: Select all
@echo off
find "ERROR:XXXX" <logs.txt >nul && (
net stop "servicename"
net start "servicename"
)
Re: dos command to read a text file
Hi foxidrive, thanks for the quick response.
How if it cannot find the "ERROR:XXXX"? Will it still restart the services based on your suggested script?
My requirement is, the services will only be restarted if the string "ERROR:XXXX" is found.
How if it cannot find the "ERROR:XXXX"? Will it still restart the services based on your suggested script?
My requirement is, the services will only be restarted if the string "ERROR:XXXX" is found.
Re: dos command to read a text file
dosnoob wrote:Hi foxidrive, thanks for the quick response.
How if it cannot find the "ERROR:XXXX"? Will it still restart the services based on your suggested script?
My requirement is, the services will only be restarted if the string "ERROR:XXXX" is found.
If the term "ERROR:XXXX" is not found then it will do nothing.
Re: dos command to read a text file
Youre the man foxidrive.. Thanks