I've a Program2.bat
having Oracle query, which generates a file log.txt
having content-structure either like:
SQL> SELECT SID, SERIAL#, STATUS, USERNAME, LOGON_TIME FROM GV$SESSION WHERE USERNAME = 'DBADMIN' and status in ('ACTIVE','INACTIVE','KILLED') ;
no rows selected
SQL> spool off;
OR like:
SQL> SELECT SID, SERIAL#, STATUS, USERNAME, LOGON_TIME FROM GV$SESSION WHERE USERNAME = 'DBADMIN' and status in ('ACTIVE','INACTIVE','KILLED') ;
SID SERIAL# STATUS USERNAME LOGON_TI
---------- ---------- ---------- ---------- -------------
2388 54 Active DBADMIN 28-FEB-14
2391 37 Active DBADMIN 17-FEB-14
2395 111 Inactive DBADMIN 28-FEB-14
2780 325 Killed DBADMIN 26-FEB-14
2790 111 Killed DBADMIN 8-FEB-14
5 rows selected.
SQL> spool off
I'm trying to achieve following things:
- Action-1: Call Program2.bat, which will generate log.txt
- Action-2: Search for the string "no rows selected" in log.txt
- Action-3: If string found then call program1.bat
Action-4: If string not found then do below:
call program2.bat again and
Do Action-2 again at an interval of 5 mins (means keep searching for string "no rows selected" in log.txt on an interval of 5 mins untill string "no rows selected" got found ).
@echo off setlocal Call Program2.bat >nul findstr /c:"no rows selected" log.txt && ( call program1.bat ) || ( call program2.bat )
How Point-2 of Action-4 can be achieved in above script or do we have any other way to achieve all in the easiest way?