Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 30 Oct 2008 10:41:00 -0400
From:      Jerry McAllister <jerrymc@msu.edu>
To:        d@delphij.net
Cc:        stable@freebsd.org, Eduardo Meyer <dudu.meyer@gmail.com>, questions@freebsd.org
Subject:   Re: Script-friendly (parseble) ps(1) output?
Message-ID:  <20081030144100.GA12264@gizmo.acns.msu.edu>
In-Reply-To: <4908EE91.1080706@delphij.net>
References:  <d3ea75b30810291502h716ae979r9906a7a053ec5f56@mail.gmail.com> <4908EE91.1080706@delphij.net>

next in thread | previous in thread | raw e-mail | index | archive | help
On Wed, Oct 29, 2008 at 04:15:29PM -0700, Xin LI wrote:

> -----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?

Well, first pick a language.
This would be easy in PHP or Perl or other similar scripting 
interpreter languages.   If you pick one and then study it
a little - write a few simple practice scripts, you will 
probably quickly see how to do it.

////jerry

> 
> 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@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-----
> _______________________________________________
> freebsd-questions@freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-questions
> To unsubscribe, send any mail to "freebsd-questions-unsubscribe@freebsd.org"



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20081030144100.GA12264>