views:

651

answers:

2

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?

+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
Whitespace isn't removed, it's replaced with NULs.
bdonlan
@bdonlan Ah, I did not check that. Good catch!
lothar
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
On my system there is no /proc filesystem :(any other solution ?
Hemant
+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
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