Re: Script-friendly (parseble) ps(1) output?
Marian Hettwer wrote: [ .. ] > I wouldn't do that. IIRC procfs(5) is deprecated in FreeBSD. > But I could be wrong... Just wanted to point out since discussion of procfs came up - I think this was FreeBSD6.2 IIRC, I had to mount /proc manually for a Java application to work because the code was implemented in Linux using JDK1.5 and a day came when our app had to run on FreeBSD =:-P). I still remember we had a heck of time trying to find a solution! This could probably help some poor little bugger searching for solution in the future. -- en0f ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to "[EMAIL PROTECTED]"
Re: Script-friendly (parseble) ps(1) output?
Hi, On Thu, 30 Oct 2008 17:45:12 +0200, Aragon Gouveia <[EMAIL PROTECTED]> wrote: > | By Eduardo Meyer <[EMAIL PROTECTED]> > | [ 2008-10-30 00:04 +0200 ] >> 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. > > Another option might be to mount /proc and use that instead. See > procfs(5). > I wouldn't do that. IIRC procfs(5) is deprecated in FreeBSD. But I could be wrong... regards, Marian ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to "[EMAIL PROTECTED]"
Re: Script-friendly (parseble) ps(1) output?
| By Eduardo Meyer <[EMAIL PROTECTED]> | [ 2008-10-30 00:04 +0200 ] > 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. Another option might be to mount /proc and use that instead. See procfs(5). Regards, Aragon ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to "[EMAIL PROTECTED]"
Re: Script-friendly (parseble) ps(1) output?
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 <[EMAIL PROTECTED]>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 "[EMAIL PROTECTED]" ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to "[EMAIL PROTECTED]"
Re: Script-friendly (parseble) ps(1) output?
On Wednesday 29 October 2008 23:02:43 Eduardo Meyer wrote: > ps -ax -o pid -o user -o emul -o lstart -o lockname -o stat -o command First of all you will want -ww, since the command will otherwise be truncated. Secondly, you can comma seperate the -o arguments for brevity, so: ps -awwx -o pid,user,emul,lstart,lockname,stat,command will be your command. You forgot to mention what language your CGI will be in, so I'll just give you the simplest algorithm: - read the first line - record position of the first character after a space character, by simply walking the line char by char - Using those positional numbers it is now trivial to extract the information from the rest of the lines. -- Mel Problem with today's modular software: they start with the modules and never get to the software part. ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to "[EMAIL PROTECTED]"
Re: Script-friendly (parseble) ps(1) output?
On Oct 29, 2008, at 3:02 PM, Eduardo Meyer 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. Rather than rolling your own web-based admin tool, why not try something like sysutils/webmin? It's got a "Running Processes" table which lets you send signals like HUP, KILL, etc by clicking a button -- -Chuck ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to "[EMAIL PROTECTED]"
Re: Script-friendly (parseble) ps(1) output?
On Wed, 29 Oct 2008 20:02:43 -0200, "Eduardo Meyer" <[EMAIL PROTECTED]> 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("%s%s%s%s%s\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, ... ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to "[EMAIL PROTECTED]"
Re: Script-friendly (parseble) ps(1) output?
The output I get from that command is pretty much aligned in columns. Maybe you can extract the columns with cut -c. On Oct 29, 2008, at 6:02 PM, Eduardo Meyer wrote: ps -ax -o pid -o user -o emul -o lstart -o lockname -o stat -o command ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to "[EMAIL PROTECTED]"
Re: Script-friendly (parseble) ps(1) output?
-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 <[EMAIL PROTECTED]> 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 "[EMAIL PROTECTED]"