Operating System - HP-UX
1752790 Members
6962 Online
108789 Solutions
New Discussion юеВ

Re: How to get full path of a process listed on ps output

 
villarre
Occasional Contributor

How to get full path of a process listed on ps output

Hi, I need to know the full path of a process I see on the ps output / top output :

$ ps -ef | grep event_demon
autosys 25876 1 0 Jun 2 ? 3419:44 event_demon -A PPE -R
autosys 3092 1 0 Jun 5 ? 3228:04 event_demon -A PQE -R
gzdz51 16813 14788 0 10:46:20 pts/3 0:00 grep event_demon
$ uname
HP-UX
$ uname -a
HP-UX uspls005 B.11.31 U ia64 1164653830 unlimited-user license
$

I cannot determine what started those event_demon, maybe knowing its location will help me. Does anybody know if that is possible to get?

 

Thanks!!

5 REPLIES 5
Torsten.
Acclaimed Contributor

Re: How to get full path of a process listed on ps output

Since parent PID is 1 it is most likely started by init.

But maybe "whence" or "whereis" can help you.

 

Google points to ca autosys product.


Hope this helps!
Regards
Torsten.

__________________________________________________
There are only 10 types of people in the world -
those who understand binary, and those who don't.

__________________________________________________
No support by private messages. Please ask the forum!

If you feel this was helpful please click the KUDOS! thumb below!   
Dennis Handly
Acclaimed Contributor

Re: How to get full path of a process listed on ps output

lsof(1m) may provide this info given the PID?

 

Otherwise you can get out your trusty "find(1) -name event_demon" and scan files systems.  :-)

Santosh Abraham
Advisor

Re: How to get full path of a process listed on ps output

Have you tried pstat_getcommandline() ?

Santosh Abraham
Advisor

Re: How to get full path of a process listed on ps output


@Santosh Abraham wrote:

Have you tried pstat_getcommandline() ?


Sorry - ignore the above.  I did not grok your question correctly.  If you have super-user access and are inclined to a bit of programming perhaps the following might work:-

 -------------------------------<snip>----------------------

char filename[PATH_MAX+1];
  struct pst_status ps;

  if (pstat_getproc(&ps,sizeof(ps),0,pid_of_prog_u_r_interested_in)) == -1) {
    perror("pstat_getproc");
    return -1;
  }

  if (pstat_getpathname(filename,sizeof(filename),&ps.pst_fid_text) == -1) {
    perror("pstat_getpathname");
    return -1;
  }

--------------------------<snip>----------------------------

Bill Hassell
Honored Contributor

Re: How to get full path of a process listed on ps output

There is no substitute for pstree.

pstree -p <any_PID>

will show you the entire top-to-bottom parent-child relationship.

Just give it *any* PID and the entire tree will be shown.

# pstree -p 17186
-+- 00001 root init
 \-+- 01894 root /usr/local/sbin/sshd
   \-+- 16910 root sshd: root@pts/0
     \-+- 16912 root -sh
       \-+- 17186 root /usr/bin/ksh cfg2html -o /tmp
         \-+- 18130 root /usr/bin/ksh cfg2html -o /tmp
           \-+- 18133 root fold -w160
             |--- 18137 root expand
             \-+- 18134 root /usr/bin/ksh cfg2html -o /tmp
               \-+- 18135 root /usr/bin/sh /opt/hpsmh/bin/smhassist
                 \-+- 18138 root /opt/perl/bin/perl /opt/hpsmh/bin/smhassist.pl
                   \--- 18140 root /usr/sbin/swverify -x autoselect_dependencies.. 

Here are all the options:

pstree $Revision: 2.33 $ by Fred Hucht (C) 1993-2007
EMail: fred AT thp.Uni-Duisburg.de

Usage: pstree [-f file] [-g n] [-u user] [-U] [-s string] [-p pid] [-w] [pid ...]
   -f file   read input from <file> (- is stdin) instead of running
             "ps -ef"
   -g n      use graphics chars for tree. n=1: IBM-850, n=2: VT100, n=3: UTF-8
   -l n      print tree to n level deep
   -u user   show only branches containing processes of <user>
   -U        don't show branches containing only root processes
   -s string show only branches containing process with <string> in commandline
   -p pid    show only branches containing process <pid>
   -w        wide output, not truncated to window width
   pid ...   process ids to start from, default is 1 (init)
             use 0 to also show kernel processes

It is mandatory for my toolbox, just like lsof and tusc.

Get a copy here: ftp://ftp.sourcedirect.com/pub/tools/pstree/

 



Bill Hassell, sysadmin