1753726 Members
4715 Online
108799 Solutions
New Discussion юеВ

Getting the exit status

 
SOLVED
Go to solution
Chandramani
Occasional Contributor

Getting the exit status

Hi there,
I am trying the following script to read its exit status and depending on that I want to run my program.
-----------------------------------
hostname=`hostname`
BVSTAT=0

ps -eaf|grep bvtst|grep bv|grep -v grep|grep -v ksh > /dev/null

if [[ $? -eq 0 ]]
then
BVSTAT=1
fi
----------------------------------

I am able to get BVSTAT value when I run on the same host.If I am trying to run the above script remotely means using rsh or pbrun.In that case I am not get the exit status,so I am not getting proper output to my program.

Can anyone help me on this which can give exit status even from remote system.

Secnario:

SystemA and SystemB

When I run on systemA I am getting the value of BVSTAT

When I run on systemB using rsh or pbrun I am not getting the value for BVSTAT


Please help me.

-Nag
3 REPLIES 3
A. Clay Stephenson
Acclaimed Contributor

Re: Getting the exit status

Hi:

There is no direct way to do this since $? only indicates that remsh was able to be launched. To get the remote exit status it more complicated but it can be done. See this thread:
http://forums.itrc.hp.com/cm/QuestionAnswer/1,,0x7e2d8ffa98a2d5118ff10090279cd0f9,00.html
If it ain't broke, I can fix that.
Sachin Patel
Honored Contributor

Re: Getting the exit status

Hi Chandramani,

If you are trying to find out that bvstat is running on remote system then

for sys in systemA systemB
do
STAT=`remsh $sys ps -e |grep bvstat|wc -l`
if [ $STAT -ge 1 ] ; then
echo "it is running"
fi
done

Sachin
Is photography a hobby or another way to spend $
Mark Greene_1
Honored Contributor
Solution

Re: Getting the exit status

Try this:

hostname=`hostname`
BVSTAT=0

BV_PS=`ps -eaf|grep bvtst|grep bv|grep -v grep|grep -v ksh`

if [[ -n ${BV_PS} ]]
then
BVSTAT=1
fi


HTH
mark
the future will be a lot like now, only later