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

Polytropon freebsd at edvax.de
Wed Oct 29 17:37:26 PDT 2008


On Wed, 29 Oct 2008 20:02:43 -0200, "Eduardo Meyer" <dudu.meyer at gmail.com> wrote:
> 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.

If you can use awk, it's quite simple:

ps | awk -F " " 'NR > 1 {printf("<td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td>\n", $1, $2, $3, $4, $5);}'

The only problem I see is that $5, the COMMAND field, is truncated
after the first space character, so command line arguments will be
missing.


-- 
Polytropon
>From Magdeburg, Germany
Happy FreeBSD user since 4.0
Andra moi ennepe, Mousa, ...


More information about the freebsd-questions mailing list