|
Answer» Hi All,
I am trying to WRITE a bat file that should check for a particular entry within a file. On FINDING, it should proceed to the next step or terminate right there.
I have managed to put in the following piece of code but it's not helping me with what I want to do:
Code: [Select]ECHO OFF REM========================================
SET LOG=\tmp\check.log
REM ==================================================== REM 1) Check for entry "A" REM ==================================================== E: CD \ABC
IF EXIST temp.log.(FINDSTR "A" temp.log.)ELSE echo temp.log. missing >>%LOG% IF %ERRORLEVEL% NEQ 0 ( ECHO FAILED to find entry A in temp.log >>%LOG% goto EXITERROR ) ELSE ( goto step2 )
REM ==================================================== REM 2) Check for entry "B" REM ==================================================== :step2 E: cd \ABC
IF EXIST temp.log.(FINDSTR "B" temp.log.)ELSE echo temp.log. missing >>%LOG% IF %ERRORLEVEL% NEQ 0 ( ECHO Failed to find entry B in temp.log >>%LOG% goto EXITERROR ) ELSE ( goto step3 )
REM ==================================================== REM 3) Check for entry "C" REM ==================================================== :step3 E: cd \ABC
IF EXIST temp.log.(FINDSTR "C" temp.log.)ELSE echo temp.log. missing >>%LOG% IF %ERRORLEVEL% NEQ 0 ( ECHO Failed to find entry C in temp.log >>%LOG% goto EXITERROR ) ELSE ( ECHO All entries found in the file>>%LOG% )
REM ========================== REM ERROR Code REM ========================== :EXITERROR The file temp.log resides under the folder ABC under E: drive. I want to check for the entry "A" within this file before proceeding with the next step. The script should simply go to the next step if it finds, otherwise it should exit by alerting the user.
Please can you help? I am testing this on Windows 2003 Server.
Many thanks
No need to double post. I'm locking this thread.
|