On SunOS there is pargs command that prints the command line aruguments passed to the running process. Is there is any similar command on other Unix environments?
views:
651answers:
2
+1
A:
On Linux
cat /proc/<pid>/cmdline
get's you the commandline of the process (including args) but with all whitespaces changed to NUL characters.
lothar
2009-05-04 20:24:56
Whitespace isn't removed, it's replaced with NULs.
bdonlan
2009-05-05 00:34:21
@bdonlan Ah, I did not check that. Good catch!
lothar
2009-05-05 00:58:34
xargs -0 echo < /proc/<pid>/cmdline . You can also do this with /proc/<pid>/environ too, although you may want to add -n 1 for that.
camh
2009-05-05 12:02:57
On my system there is no /proc filesystem :(any other solution ?
Hemant
2009-05-06 06:20:12
+8
A:
There are several options:
ps -fp <pid>
cat /<pid>/cmdline
There is more info in /proc/<pid>
on Linux, just have a look.
On other Unixes things might be different. The ps command will work everywhere, the /proc stuff is OS quite specific. For example on AIX there is no cmdline in /proc.
markus_b
2009-05-04 20:26:54
on linux, you'll probably need -ww (ie `ps -ww -fp <pid>`) to specify wide output since if there are several commands, they could get cut off.
Silfheed
2009-05-06 18:59:38