Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re: parsing output of UNIX `who` command

by spadacciniweb (Curate)
on Oct 02, 2006 at 08:39 UTC ( [id://575850]=note: print w/replies, xml ) Need Help??


in reply to parsing output of UNIX `who` command

Try:
#!/usr/bin/perl use warnings; use strict; my $who = `who -q`; if ($who =~ /(.+)\n# users/) { $who = $1; } my @who = split / /,$who; my %who; foreach $_ (@who) { $who{$_}++; } foreach $_ (keys(%who)) { print $_, ' is logged ', $who{$_}, " times\n"; }

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://575850]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (6)
As of 2024-04-19 13:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found