
Using Runable Solutions
Creating Scripts and Programs
Finding Cases and Using the Library SpectroRx (SPECTRUM Resolution Expert)
5-6 User’s Guide 5.0rev1
Figure 5-2. Sample Script
#!/bin/sh
######################################################################
#
# The script "restart" restarts various daemons and applications.
# The first argument, $1, specifies what is to be restarted.
# Below we have implemented a script that can check whether
# a SunOS snmpd is running. If the snmpd is not running, the script
# tries to restart it.
#
# The syntax of "restart" is:
#
# restart item arg1 arg2 ...
#
# Below, "item" is "snmpd", arg1 is the domain in which the item is
# located, and arg2 is the name of the item.
#
#######################################################################
case $1 in
snmpd) ## $2 is the domain name
## $3 is the device name
## Example: restart snmpd north_atlanta wiz1
running=`rsh $3 ps -aux | grep snmpd`
if test "$running"
then
echo The snmp daemon on server $3 in domain $2 is running
echo on `date`. No action taken.
else
result=`rsh "$3" /usr/etc/snmpd`
echo Attempted to restart the snmp daemon on server $3 in
echo domain $2 on `date`.
echo The result was $result
fi ;;
*) echo Command not recognized ;;
esac
Comentários a estes Manuais