Script-friendly (parseble) ps(1) output?

Xin LI delphij at delphij.net
Wed Oct 29 16:15:41 PDT 2008


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Eduardo Meyer wrote:
> Hello,
> 
> I need to write a cgi script which will print the output from ps(1) in
> a table (html), so the average-operator can click on a KILL link and
> the cgi will send the selected signal.
> 
> I need to add one ps information per column in a table (html),
> however, I found ps(1) output to be too hard to parse. There is no
> separator. I believed \t was the separator but its not.
> 
> The ps(1) command I need to use is:
> 
> ps -ax -o pid -o user -o emul -o lstart -o lockname -o stat -o command
> 
> Since many of those args use [:space:] in the output, I can not use
> [:space:] as a separator.
> Sadly, `-o fiend='value'` will only format the HEADER output, not the values.
> 
> Ive got no clue what to do, can someone enlight me?

Perhaps use cut(1) with -c or something similar in other scripting
language?  It looks like that the output is aligned.

Cheers,
- --
Xin LI <delphij at delphij.net>	http://www.delphij.net/
FreeBSD - The Power to Serve!
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.9 (FreeBSD)

iEYEARECAAYFAkkI7pEACgkQi+vbBBjt66Bi3wCgmk9chU/FIZjuBpm/57Yl7jBY
D6kAoI6ZmQRdxDm7mzjale84p4uXmlmz
=4FMM
-----END PGP SIGNATURE-----


More information about the freebsd-stable mailing list