how many users?

Fairlight fairlite at fairlite.com
Thu Dec 5 18:23:02 PST 2013


On Thu, Dec 05, 2013 at 11:29:54AM -0500, Kenneth Brody thus spoke:
> 
> But, if dclerk system's out to dreport, you'll see two entries.
> (Actually, you'll probably see 3, including the original runmenu.)

Yes, and if you're running <= 5.6, my approach is still correct, since
system()ing off clerk and report ate another licence prior to that version.
Most of my clients are still on <= 5.0.14.

If you've got 5.6 or higher, your ideal solution is a perl script that
grabs `ps -ef` (SysV -and- linux...  Linux's procps honours -ef as SysV
flags due to the leading dash; the dash says use SysV flags, the absence of
a dash says use BSD flags), looks up every instance of all the appropriate
programs, and weeds out the clerks and reports which have a parent which is
also a clerk or report.  A one-liner is out of the question in this event.
In that case, it truly is time for a script, although `ps` only need be
consulted once, and the remainder of the manipulation can be done with
perl's internal grep() function, and an array, using split() on each line
and grabbing the appropriate fields.  Technically, you'd then not have to weed
out the keyword "grep", but you would gain the ability to use PCRE to check
for \S on both sides of all keywords within the command field, so as to
grab -only- 'rreport' and not something unrelated, like 'brokerreport'.
And if you're going to that length, you can specify a flag like
--system-counts for the script so that it -doesn't- weed out children, and
use that flag on pre-5.6 systems.

There's the loose one-liner magic, and there's the full no-holds-barred
solution that takes no prisoners and makes no mistakes, accomodating every
possible case.  

It's seeing loose one-liner magic turned into a paragraph of code that
drives me nuts.  :)

mark->
-- 
Audio panton, cogito singularis.


More information about the Filepro-list mailing list