Hi guys, I’m a novice when it comes to .bat so am hoping someone can help with this (what I think is gonna be dead obvious & simple) question!
I run some reports for servers at work, it connects to a few servers, runs 2 commands then brings back the results in a .txt for each server. I then have to look through these for the below lines in those .txts
-1
Not Sync
I’d like to automate this last bit if possible!
Currently the batch file contains this:
-------------
Set CURRDATE=%TEMP%\CURRDATE.TMP
Set CURRTIME=%TEMP%\CURRTIME.TMP
DATE /T > %CURRDATE%
TIME /T > %CURRTIME%
Set PARSEARG="eol=; tokens=1,2,3,4* delims=/, "
For /F %PARSEARG% %%i in (%CURRDATE%) Do SET YYYYMMDD=%%k%%j%%i
del errorDQG0.txt
psexec \\IP ADDRESS -u .\USER -p PASSWORD dscontrol.cmd manager report >> DQG0_farm_check_%YYYYMMDD%.txt
psexec \\IP ADDRESS -u .\USER -p PASSWORD dscontrol.cmd higha status >> DQG0_farm_check_%YYYYMMDD%.txt
find "-1" “Not Sync” DQG0_farm_check_%YYYYMMDD%.txt
::find "-1" DQG0_farm_check_%YYYYMMDD%.txt
if errorlevel 1 copy DQG0_farm_check_%YYYYMMDD%.txt errorDQG0.txt
del DQG0_farm_check_%YYYYMMDD%.txt
pause
---------------------
(one line commented out on purpose for now)
But this doesn't bring back results in ‘errorDQG0.txt’ whether it finds the strings or not! Another edit I made (which was error level 0) DOES create a file but whether it finds the string or not!
How can I write it so that
a) It only gives me an errorxxxx.txt file if it DOES find ‘-1’ or ‘Not Sync’ (xxxx will be the server name)
b) I can tell it to search for both strings in one go. (just put "-1" "Not Sync" ??
c) For future use, it gives one error.txt file containing ALL servers with errors rather than individual text files.
Thanks for any help guys!!