Batch Script to issue a command, store output, exit when Operator hits 'enter'
Posted on 2009-05-08
I have a need to make a batch script of some sort to issue a command to shutdown, startup, or status an Oracle service running in Windows. I am hoping to use the script you help me build to also issue sqlplus commands to shutdown/startup the Oracle database & listener.
My thoughts are that the user would click an icon on the desktop that opens a window where you could view the command being issued and the screen output. When the command finishes, the screen remains until the operator presses enter or clicks something to acknowledge the completion.
If there are errors with the command that the user sees on the screen, rather than rely solely on the user's description of the error, I'd like the screen output to be sent to a log file.
In my perfect world, this script would ask the user which function they are performing ("start", "stop", or "status" the service). It would display the output from the command on the screen and also send the output to a log file. And remain on the screen until the operator can confirm the success or failure of the command before closing the window.
I tried to put something together but the DOS window that opens disappears immediately after the command is finished. I've got no log and it's amature. I need something that my grandmother can execute and be able to see whether it was successful or not.
The commands being entered to status the service are:
set ORACLE_SID=orcl <--this must be set automatically in the script.
cd E:\oracle\product\10.2.0\db_1\bin <-- this is the directory that the command resides.
emctl status dbconsole <-- this is the command itself
The commands being entered to stop the service are:
emctl stop dbconsole
The commands to start the service are:
emctl start dbconsole
I'd like the log sent to directory "E:\oracle\product\10.2.0\Scripts\OperatorScripts"
Thank you very much.