On HPUX, how do I list the full path to the executable for all running processes?

1

What I need: A list of all currently running executables with their full path.

Something like this:

1234 /full/path/to/executable
4567 /full/path/to/executable2

Using UNIX95= ps -exo pid,comm I can get a list with PIDs and the commands like this

11146 /opt/wbem/lbin/cimprovagt 0 4 8 root IOTreeModule
8338 /opt/ssh/libexec/sftp-server
16684 postgres: sfmdb evweb [local] idle
2518 /usr/sbin/stm/uut/bin/tools/monitor/WbemWrapperMonitor
2264 /usr/sbin/psb/bin/diagtxd
8340 -sh
7772 sshd: root@pts/0
8333 sshd: root@pts/1
7777 /opt/ssh/libexec/sftp-server

This is as close I've managed to get using ps, but it is not good enough:

  • Some lines do not include the full path (apparently because they are not started using the full path).
  • Extra data after the executable name (I need to support executables with spaces in their name so I can't just split the string)

As such, I've concluded that ps won't get me all the way.

Is there an equivalent to Linux's /proc where /proc/{pid}/exe points to the executable? If not, is there another way to accomplish this?

Thanks in advance,

Per

Posted 2016-06-20T12:08:42.090

Reputation: 283

Answers

0

pfiles <pid> can list the full path to the executable.

Example:

Snippet from UNIX95=1 ps -efo pid,comm

 1666 cimprovagt

Now lets run pfiles 1666

1666:                   /opt/wbem/lbin/cimprovagt
0: S_ISCHR mode:666 dev:64,3 ino:124 uid:2 gid:2 rdev:3,2
flags = O_RDONLY|O_LARGEFILE
file  = /dev/null

The first line shows the full path to executable. This is good enough for my purposes.

Per

Posted 2016-06-20T12:08:42.090

Reputation: 283