Re: new guy ksh scripting questions
- From: "j3" <jeffrey_e_ross2@xxxxxxxxxxx>
- Date: 21 Sep 2006 17:37:37 -0700
FNG2007 wrote:
I've been given the task of writing the following procedure into a
script to be called from the crontab of the Oracle user.
I'm a Windows Admin, newly minted into an AIX sysadmin - and I'm a bit
bewildered by ksh scripting.
I've got one of the O'Reilly books and I'm hacking my way through it -
but I'm still having problems with some of the basics like
a) on step 4 below, how would I verify that I've got 4 processes that
all return the ALIVE status. My thought is to pipe the output of the
command into a grep command looking for ALIVE, pipe that into a wc -l
command and have it return an error if the output from that is less
than 4. But I'm sure there's got to be a smarter way to do that.
ANyway, as I said, I'm slogging through it on my own - I thought I'd
throw the problem up here to see if anyone had any sage advice or
warnings about pitfalls to avoid
thanks in advance
=========================
1. While logged in as Oracle, stop the LDAP services by executing the
following commands:
. ./.profile_as
cd bin
./Shutdown.sh
2. Verify that the services are not running:
opmnctl status
The result of this command should look like this:
[oracle@hostname1/home/oracle]$ opmnctl statusUnable to connect to opmn.
Opmn may not be up.
ps -ef |grep ldap
This command should not return any running ldap processes.
ps -ef |grep oid
This command should not return any running oid processes.
3. Start the services executing the following command:
./Startup.sh
4. Verify that the services are running:
opmnctl status
The result of this command should look like this:
Processes in Instance: infra.hostname.acme.corp
-------------------+--------------------+--------+---------
ias-component | process-type | pid | status
-------------------+--------------------+--------+---------
OID | OID | 581734 | Alive
OC4J | ldapapp | 966658 | Alive
OC4J | OC4J_SECURITY | 561208 | Alive
HTTP_Server | HTTP_Server | 10118~ | Alive
dcm-daemon | dcm-daemon | N/A | Down
LogLoader | logloaderd | N/A | Down
5. Verify that ldap demons are running on SSL and non-SSL ports:
netstat -an | grep 389 | grep LISTEN
tcp4 0 0 172.50.1.104.389 *.*
LISTEN
and:
netstat -an | grep 636 | grep LISTEN
tcp4 0 0 172.50.1.104.636 *.*
LISTEN
What you're doing is fine.
You can use "netstat -an | grep -q '\.389 .*LISTEN' " which will
quietly grep for ".389" followed by a space, any number of any
character, and "LISTEN". If this matches the grep will exit with
success, otherwise with failure. That can be used in your script, eg
if netstat | grep
then echo good
else echo bad
fi
With your step 2 problem an optimisation is to use grep -c, which will
count the number of matching lines and print that number on stdout.
if [ `opmnctl status | grep -c ALIVE` = 4 ]
then echo good
else echo bad
fi
HTH and hang in there - Unix is grotesque but powerful.
Jeffrey
.
- References:
- new guy ksh scripting questions
- From: FNG2007
- new guy ksh scripting questions
- Prev by Date: new guy ksh scripting questions
- Next by Date: AIX 5.3 rdist installs files in home directory, not target directory
- Previous by thread: new guy ksh scripting questions
- Next by thread: Re: new guy ksh scripting questions
- Index(es):
Relevant Pages
|