home *** CD-ROM | disk | FTP | other *** search
/ ftp.muug.mb.ca / 2014.06.ftp.muug.mb.ca.tar / ftp.muug.mb.ca / pub / src / perl / eg / who < prev   
Text File  |  1992-04-11  |  435b  |  14 lines

  1. #!/usr/bin/perl
  2. # This assumes your /etc/utmp file looks like ours
  3. open(UTMP,'/etc/utmp');
  4. @mo = (Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec);
  5. while (read(UTMP,$utmp,36)) {
  6.     ($line,$name,$host,$time) = unpack('A8A8A16l',$utmp);
  7.     if ($name) {
  8.     $host = "($host)" if $host;
  9.     ($sec,$min,$hour,$mday,$mon) = localtime($time);
  10.     printf "%-9s%-8s%s %2d %02d:%02d   %s\n",
  11.       $name,$line,$mo[$mon],$mday,$hour,$min,$host;
  12.     }
  13. }   
  14.