Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: parsing output of UNIX `who` command

by gellyfish (Monsignor)
on Oct 02, 2006 at 09:21 UTC ( #575851=note: print w/replies, xml ) Need Help??


in reply to parsing output of UNIX `who` command

As an alternative to parsing the output of the external command you might consider using Sys::Utmp:

use Sys::Utmp; + my $utmp = Sys::Utmp->new(); + my %users; + while ( my $utent = $utmp->getutent() ) { if ( $utent->user_process ) { $users{$utent->ut_user}++; } } + $utmp->endutent; + foreach my $user (keys %users) { printf "%s is logged in %d times\n", $user, $users{$user}; }

/J\

Replies are listed 'Best First'.
Re^2: parsing output of UNIX `who` command
by chinamox (Scribe) on Oct 02, 2006 at 10:12 UTC
    You are a saint among monks. Thank you.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://575851]
help
Chatterbox?
[ambrus]: MLX: if it's a work email, then it's probably not Uncle Sam that matters, but what the account managing server at work thinks your name is. Those can differ. For example, we've had two co-workers with identical real name at one point,
[ambrus]: so one got a stupid suffix in the email account (people have email address based on their real name here usually).

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (14)
As of 2017-01-19 14:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you watch meteor showers?




    Results (170 votes). Check out past polls.