Operating System - HP-UX
1830169 Members
6697 Online
109999 Solutions
New Discussion

Strange out put from same script on different systems.

 
Rajesh SB
Esteemed Contributor

Strange out put from same script on different systems.

Hi,

I am running a shell script on (L-Class)one Server. It is checking that whether same script is running properly or not.
command used inside the script

" echo `ps -ef|grep -v grep|grep nprparser_start.sh` "

O/P is

metrica 1601 1476 3 13:16:20 pts/0 0:00 sh -v nprparser_start.sh
metrica 26972 26719 3 16:03:13 pts/1 0:00 /usr/bin/sh ./nprparser_start.sh

When I run the same script on another m/c (K-Class),

O/P I am getting
metrica 26992 26972 0 16:03:13 pts/1 0:00 ./nprparser_start.sh ./nprparser_start.sh

metrica 26972 26719 3 16:03:13 pts/1 0:00 ./nprparser_start.sh ./nprparser_start.sh

Script is defined to run using POSIX Shell "/usr/bin/sh".

With the same environment setting on the both m/cs for user. But getting different output.

Any pointer.

Thanks in advance.

Rajesh
5 REPLIES 5
John Poff
Honored Contributor

Re: Strange out put from same script on different systems.

Hi,

It looks like the first box is running your script from two different terminals [pts/0 and pts/1]. The first terminal invoked the script with a 'sh -v' command while the second script just used 'sh' to run it. On the second box, the script appears to have been run by invoking the script name from the command line. How are you running the scripts on each system? By command line, from another script, etc.?

Also, another way of checking to see if your script is running is to use the -C option to specify the command that is running. That option is for XPG4 only, so you have to set the UNIX95 variable, like this:

UNIX95=1 ps -C nprparser_start.sh

Which saves you a bit of processing and also you don't have to do the 'grep -v grep' craziness.

JP
Michael Steele_2
Honored Contributor
James R. Ferguson
Acclaimed Contributor

Re: Strange out put from same script on different systems.

Hi:

Using 'ps -ef|grep token|grep -v'...syntax isn't the most rigorous way to monitor a process by name. I suspect that do to command line limitations and/or timing that you are seeing (or not seeing) the additional information.

A better approach is to do:

# UNIX95= ps -fC |awk 'NR>1'

This will deliver (or not) the process information for . See the 'ps' man pages and the XPG4 (UNIX95) option.

Regards!

...JRF...
Colin Topliss
Esteemed Contributor

Re: Strange out put from same script on different systems.

Are both servers running the same version of the OS? I saw this type of difference between HPUX-11 and HPUX-11i (something to do with a change in the way pstat was implemented I seem to recall).

Several scripts we had started fo fail because the command was prefixed by the full path to the shell (in our case perl) - sort of what you're seeing on your L-Class.

Col.
Steve Steel
Honored Contributor

Re: Strange out put from same script on different systems.

Hi

Machine 2 the start time is the same and the
tty number is the same

machine 1 the ttys and start number are different

O/P is

metrica 1601 1476 3 13:16:20 pts/0 0:00 sh -v nprparser_start.sh
metrica 26972 26719 3 16:03:13 pts/1 0:00 /usr/bin/sh ./nprparser_start.sh

Thhe first script start at 13:16 the second at 16:03 and that is why it is different

There is probably a fault on this machine


Steve Steel
If you want truly to understand something, try to change it. (Kurt Lewin)