There is a simple line command controller called the Listener Controller (lsnrctl) that can be used to start and stop a Net listener.
Let us take a look at how this works. The following simulation starts up a listener on Windows NT. You must be at the operating system command prompt to begin. For this example, we are using Windows NT with an MS-DOS prompt screen.
The same commands work on the UNIX and Linux platforms.
Navigate through the simulation to see how to use the Listener Controller.
Start net8 services with line commands
As you can see from the simulation, the Listener Controller uses simple commands to control the background listener processes on your computer.
The next lesson will describe the uses of the Net Configuration Assistant.
How do I write a shell script to start my listener?
In addition, I also want to write a script to check to see if my listener is running.
This script uses the exit status from the lsnrctl command to determine the success or failure of the command.
If lsnrctl status returns a 0 we know the command ran successfully and the listener is running.
In this case, the script does not send any notifications, instead it just removes the temp file.
If, however, the lsnrctl has a non-zero exit status we know there is a problem.
The script will then execute a
command and send an email.
# If a SID is provided as an argument it will be set and oraenv run
# otherwise we will use the current SID. If no SID is set or provided
# an error message is displayed and the script exits with a status of 1
if [ $1 ]
if [ ! $ORACLE_SID ]
echo "Error: No ORACLE_SID set or provided as an argument"
# Now check the listener status with ps -ef | grep -i lsnr
# Then re-start the listener if it has crashed and send an e-mail alert