|
Answer» I'm new to adding errorlevel logic into a BATCH file and looking for some help.
The script I have runs a few SQL COMMANDS via OSQL and want to be notifyied if one step fails (for one reason or another) and echo out the issue into a file and email me.
echo on :Step 1 : Call Backup_Database.bat to shutdown PS environment c: CD c:\scripts\HR83RPT ECHO Backing Database CALL Backup_Database.bat PAUSE
:Step 3 :use osql to kill any active user sessions CD c:\scripts\HR83RPT osql -S ZVMPSESQL01 -U sa -P squamish -i c:\scripts\HR83RPT\uspkill.txt >> c:\scripts\HR83RPT\HR83RPT_refresh.txt echo User sessions have been terminated PAUSE
:Step 4 :use isql COMMAND to KICK off refresh executing refresh script CD c:\scripts\HR83RPT echo Refreshing Database isql -S ZVMPSESQL01 -U sa -P squamish -i c:\scripts\HR83RPT\HR83RPT.sql >> c:\scripts\HR83RPT\HR83RPT_refresh.txt echo Database Refreshed
echo %DATE% %Time% >> c:\scripts\HR83RPT\HR83RPT_refresh.txt PAUSE
:Step 6 :Send Refresh log CD c:\scripts\hr83rpt echo Sending Refresh log file CALL Refresh_Log.cmd
:error
Currently Refresh_Log.cmd above sends a list of all actions performed above and mails out to me.
Appreciate replies.
|