[aklug] Re: Portability question

From: Christopher Howard <choward@indicium.us>
Date: Thu May 21 2009 - 10:11:35 AKDT

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

Royce Williams wrote:
> bryanm@acsalaska.net wrote, on 5/20/2009 11:29 PM:
>> On Wed, May 20, 2009 6:20 pm, Royce Williams wrote:
>>> Christopher Howard wrote, on 5/20/2009 5:34 PM:
>>>> Hi. Is the command "ps -e u" available on all *nix systems? (I.e.,
>>>> POSIX-compliant systems.) And does it generate the same output as in Linux?
>>>>
>>>> Even if you could just speak for your personal non-Linux OS, that would
>>>> be helpful.
>>> Depends on how portable you need it to be. :-)
>>>
>>> royce@heffalump$ uname -nr
>>> heffalump.prv.tycho.org 7.2-RELEASE
>
>> Note that Christopher put a space in the middle: "ps -e u".
>>
>> Slackware Linux uses procps, which takes options of three
>> different kinds: single, double, and no dash. I'd be surprised
>> if there was much portability across different OSes.
>
> Ah, right - Jeff pointed that out as well.
>
> 'u' as a standalone argument isn't supported.
>
> royce@heffalump$ ps -e u
> ps: Process environment requires procfs(5)
> ps: illegal argument: u
> usage: ps [-aCcefHhjlmrSTuvwXxZ] [-O fmt | -o fmt] [-G gid[,gid...]]
> [-M core] [-N system]
> [-p pid[,pid...]] [-t tty[,tty...]] [-U user[,user...]]
> ps [-L]
>
> So, Christopher - let's take another tack. What cross-platform activity are you trying to accomplish? Maybe that could help us find the right syntax.
>
> Here's the same test on Solaris 8:
>
> royce@terminator$ uname -a
> SunOS terminator 5.8 Generic_117000-05 sun4m sparc SUNW,SPARCstation-20
> royce@terminator$ ps -e u
> usage: ps [ -aAdeflcjLPy ] [ -o format ] [ -t termlist ]
> [ -u userlist ] [ -U userlist ] [ -G grouplist ]
> [ -p proclist ] [ -g pgrplist ] [ -s sidlist ]
> 'format' is one or more of:
> user ruser group rgroup uid ruid gid rgid pid ppid pgid sid taskid
> pri opri pcpu pmem vsz rss osz nice class time etime stime
> f s c lwp nlwp psr tty addr wchan fname comm args projid project
>
> Royce
> ---------
> To unsubscribe, send email to <aklug-request@aklug.org>
> with 'unsubscribe' in the message body.
>

Yes, I should have given a context. In recent development of my
curses-based program launcher, I completed a feature that allows the
program to display, in line-by-line ticker-style, the standard output of
any program/command specified by the user. So, for example, the user
could specify the command "ps -e | grep bash", and the program would
display at the top-left hand of the screen a continuing monitor of all
processes with the name bash.

It would be ideal, upon installation of the program, that the program
would be set to display something interesting, which would demonstrate
that capability of the software. I was trying to decide which command
would be appropriate.

My first thought was to cat out the contents of a proc file, but
apparently some *nix systems don't use any or all of those files by
default. "ps -e u" seemed like another interesting possibility. I would
be open to any better suggestions, however.

The command's output is all piped into my program using popen/pclose, so
the command must be compatible with the bourne shell.

- --
Christopher Howard
http://indicium.us
http://theologia.indicium.us

I digitally sign /all/ of my e-mails via PGP. If you receive any e-mail
from me without my valid PGP signature, please take additional steps to
verify the authenticity of the message.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkoVmVcACgkQQ5FLNdi0BcX7wQCgp1eueEqElLYBFeuRHlfMKk41
fJMAoI22uasA4StDbUeh1X8shIuHCCbN
=c5sl
-----END PGP SIGNATURE-----
---------
To unsubscribe, send email to <aklug-request@aklug.org>
with 'unsubscribe' in the message body.
Received on Thu May 21 10:11:48 2009

This archive was generated by hypermail 2.1.8 : Thu May 21 2009 - 10:11:48 AKDT