Operating System - HP-UX
1848553 Members
6446 Online
104033 Solutions
New Discussion

Re: Script to view a process tree

 
Craig A. Sharp
Super Advisor

Script to view a process tree

I need a script that will show child processes similar to Solaris ptree. I need to see the child processes for each parent.
14 REPLIES 14
Rainer von Bongartz
Honored Contributor

Re: Script to view a process tree

Try

UNIX95=1 ps -Hef

Regards
Rainer
He's a real UNIX Man, sitting in his UNIX LAN making all his UNIX plans for nobody ...
Steven E. Protter
Exalted Contributor

Re: Script to view a process tree

Shalom Craig,

Just don't leave UNIX95 set all the time. It interferes with SD/UX software installation.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
James R. Ferguson
Acclaimed Contributor

Re: Script to view a process tree

Hi Craig:

# UNIX95= ps -ef -H

Regards!

...JRF...
Victor BERRIDGE
Honored Contributor

Re: Script to view a process tree

Hi Craig
Perhaps a script from HP...



All the best
Victor
Craig A. Sharp
Super Advisor

Re: Script to view a process tree

What is the default for UNIX95 and how to unset?
Craig A. Sharp
Super Advisor

Re: Script to view a process tree

When I run the UNIX95=1 ps -Hef | grep user from the command line and then echo $UNIX95. I get ksh: UNIX95: parameter not set. So I would assume that the variable is not static.
Rainer von Bongartz
Honored Contributor

Re: Script to view a process tree

Craig

UNIX95=1 ps -Hef

sets the environement UNIX95 only for the ps command.

You should NOT export UNIX95=1 , as this may conflict with certain commands



Regards
rainer
He's a real UNIX Man, sitting in his UNIX LAN making all his UNIX plans for nobody ...
Craig A. Sharp
Super Advisor

Re: Script to view a process tree

Ok, I will give it a try.
Craig A. Sharp
Super Advisor

Re: Script to view a process tree

That works great but the user has now requested something akin to an ncurses display that is interactive.

Any ideas?
James R. Ferguson
Acclaimed Contributor

Re: Script to view a process tree

Hi Craig:

Note how I wrote the command on one line.

# UNIX95= ps -ef -H

There is a space after the equal sign and then the 'ps' command.

This arms the XPG4 (UNIX95) behavior) *only* for the duration of the command line.

Regards!

...JRF...
Bill Hassell
Honored Contributor

Re: Script to view a process tree

UNIX95 is an ultra-simple flag to enable XPG4 behavior in processes and libraries. It only has to be set, so value is unimportant. UNIX95= is the least number of characters needed to defined the variable. Because the shell allows you to define a variable and run a program on the same line, the subshell gets the definition, runs the process and then disappears leaving UNIX95 undefined (as it should be for normal operation).

The ps command has an enormous number of options that most admins overlook and use grep instead. UNIX95 turns on 3 very use options: -H -C and -o. Checkout the details in the man page.


Bill Hassell, sysadmin
Rory R Hammond
Trusted Contributor

Re: Script to view a process tree

compile the program attached program

cc pswalk.c -o pswalk.

#define CMD "ps -fe|grep -v STIME" /* command to get info */

I suggest you put the full path name for ps and grep in the define statement.

I have used this for many years.

Rory
There are a 100 ways to do things and 97 of them are right
Arturo Galbiati
Esteemed Contributor

Re: Script to view a process tree

Hi,
I use the pidtree script (ksh) attached.
To see the usage type pidtree ?.
It allow me to see the process family (parents and son) starting for a given pid.
I use this to be able to kill all the process tree in one shot.
Let me know if you want the killkids script as well.
HTH,
Art
isaac_loven
Frequent Advisor

Re: Script to view a process tree

Thanks Aryuro for Yor Script. It Is GREAT.

If I could, I would give you and the others points for the great service you have provided to me and others.

It is a shame that Craig has not taken the time to thank you all, by assigning points. It is free!!

Isaac
Senior Unix Admin. Amdocs