1847250 Members
3069 Online
110263 Solutions
New Discussion

ptree & rptree

 
SOLVED
Go to solution
coollllllllllll
Regular Advisor

ptree & rptree

Hi guys ,

 

i have two scripts with me for ptree and rptree.

 

I want an o/p same as of aix proctree "pid"  which gives a tree of all assiciated child pid's only.

i do not want to reverse trace till init.

 

In forum i have got ptree , but it does not display tree process as expected.

For ex:

if i login through a user id test

and run sqlplus

and when i grep for "sqlplus" pid what i get is only the below o/p ;

 

 28453                         qryusr  sqlplus

 

What i expect is , the user name with process name also to be appeared in this o/p.

 

 

For ex:

 

28453    /oracle/bin/sqlplus
   3645536    /usr/sbin/sshd 
      3919904    sshd: pol 
      

 

 -----------------------------------------------------------------------------------------------------------------------------

P.S. This thread has been moved from HP-UX>Ignite-UX to HP-UX > languages - Forum Moderator

 

5 REPLIES 5
Dennis Handly
Acclaimed Contributor

Re: ptree & rptree

Did you want the tree displayed from the child first?

ptree(1) on 11.31 gives:

$ ptree $$
928        /opt/ssh/sbin/sshd
 15283      sshd: foobar [priv]
  15285      sshd: foobar@pts/0
   15287      -ksh
    15307      ptree 15287

 

I expect is the user name with process name

 

You would need to capture that from the ps(1) output.  Or write a program to call pstat(2).

coollllllllllll
Regular Advisor

Re: ptree & rptree

Hi Dennis ,

 

Yes.

We have 11iv2 here.

 

 

Dennis Handly
Acclaimed Contributor

Re: ptree & rptree

>We have 11iv2 here.

>In forum I have got ptree but it does not display tree process as expected.

 

Can you please attach a copy of it so we don't have to start from scratch?  :-)

coollllllllllll
Regular Advisor

Re: ptree & rptree

Hi ,

 

PFA both scripts

Dennis Handly
Acclaimed Contributor
Solution

Re: ptree & rptree

>both scripts

 

I'm still not sure what you want.

ptree.sh will start at the PID and go to all of its descendents.

rptree.sh will start at the PID and go to all of its ancestors.

 

$ ptree.sh $PPID
  10459                         foobar  sshd:
    10461                       foobar  -ksh
      4852                      foobar  /bin/sh
        4861                    foobar  ps
        4862                    foobar  sed
        4863                    foobar  sort
      15017                     foobar  vi