1.

Solve : errorlevel->help for batch file?

Answer» <html><body><p>I'm new to adding errorlevel logic into a <a href="https://interviewquestions.tuteehub.com/tag/batch-893737" style="font-weight:bold;" target="_blank" title="Click to know more about BATCH">BATCH</a> file and looking for some help.<br/><br/>The script I have runs a few SQL <a href="https://interviewquestions.tuteehub.com/tag/commands-18925" style="font-weight:bold;" target="_blank" title="Click to know more about COMMANDS">COMMANDS</a> 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.<br/><br/>echo on<br/>:Step 1<br/>: Call Backup_Database.bat to shutdown PS environment<br/>c:<br/>CD c:\scripts\HR83RPT<br/>ECHO Backing Database<br/>CALL Backup_Database.bat<br/>PAUSE<br/><br/>:Step 3<br/>:use osql to kill any active user sessions<br/>CD c:\scripts\HR83RPT<br/>osql -S ZVMPSESQL01 -U sa -P squamish -i c:\scripts\HR83RPT\uspkill.txt &gt;&gt; c:\scripts\HR83RPT\HR83RPT_refresh.txt<br/>echo User sessions have been terminated<br/>PAUSE<br/><br/>:Step 4<br/>:use isql <a href="https://interviewquestions.tuteehub.com/tag/command-11508" style="font-weight:bold;" target="_blank" title="Click to know more about COMMAND">COMMAND</a> to <a href="https://interviewquestions.tuteehub.com/tag/kick-528137" style="font-weight:bold;" target="_blank" title="Click to know more about KICK">KICK</a> off refresh executing refresh script<br/>CD c:\scripts\HR83RPT<br/>echo Refreshing Database<br/>isql -S ZVMPSESQL01 -U sa -P squamish -i c:\scripts\HR83RPT\HR83RPT.sql &gt;&gt; c:\scripts\HR83RPT\HR83RPT_refresh.txt<br/>echo Database Refreshed<br/><br/>echo %<a href="https://interviewquestions.tuteehub.com/tag/date-11316" style="font-weight:bold;" target="_blank" title="Click to know more about DATE">DATE</a>% %Time% &gt;&gt; c:\scripts\HR83RPT\HR83RPT_refresh.txt<br/>PAUSE<br/><br/>:Step 6<br/>:Send Refresh log<br/>CD c:\scripts\hr83rpt<br/>echo Sending Refresh log file<br/>CALL Refresh_Log.cmd<br/><br/>:error<br/><br/>Currently Refresh_Log.cmd above sends a list of all actions performed above and mails out to me.<br/><br/>Appreciate replies.</p></body></html>


Discussion

No Comment Found