Operating System - HP-UX
1845930 Members
3393 Online
110250 Solutions
New Discussion

Re: Scripts Problems ... Please Help Me!

 
SOLVED
Go to solution
Rafael Mendonça Braga
Regular Advisor

Scripts Problems ... Please Help Me!

Hello guys!!!
I'm going bananas with a script here!!!

The aim of the script is to check when a database process goes down.
The script is very simple... Like this one:

#-----------------------------------------
#!/usr/bin/sh

# set path to prevent trojan horses
PATH=/usr/bin:/opt/OV/bin/OpC

# Check the number of processes running

PROC=`ps -ef | grep -i $1 | grep -v grep | wc -l`

echo $PROC

#-------------------------------------------

So the problem is the following:

I call the script this way:

sh teste.sh ora_pmon_openview

Where ora_pmon_openview is the name of the process that I want to know if is running or not. This process runs once a time one my server, so the script should echo the number 1 on the screen alright?

But that's the problem... The script is returning the number 2, but when I execute the command manualy "ps -ef |grep -i ora_pmon_openview |grep -v grep |wc -l" it returns me the right number (1).

Did you see something wrong on the script?

Please, I'm counting on you!

Thanks,

Rafael M. Braga
2 REPLIES 2
harry d brown jr
Honored Contributor
Solution

Re: Scripts Problems ... Please Help Me!

It's picking up your script execution of

sh teste.sh ora_pmon_openview

in ps -ef so you need to grep it out:

grep -v -e grep -e teste.sh

live free or die
harry d brown jr
Live Free or Die
Rafael Mendonça Braga
Regular Advisor

Re: Scripts Problems ... Please Help Me!

Thanks a lot!!!