summaryrefslogtreecommitdiff
path: root/eg/who
diff options
context:
space:
mode:
Diffstat (limited to 'eg/who')
-rw-r--r--eg/who13
1 files changed, 13 insertions, 0 deletions
diff --git a/eg/who b/eg/who
new file mode 100644
index 0000000000..6543908853
--- /dev/null
+++ b/eg/who
@@ -0,0 +1,13 @@
+#!/usr/bin/perl
+# This assumes your /etc/utmp file looks like ours
+open(utmp,'/etc/utmp');
+@mo = ('Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec');
+while (read(utmp,$utmp,36)) {
+ ($line,$name,$host,$time) = unpack('A8A8A16l',$utmp);
+ if ($name) {
+ $host = "($host)" if $host;
+ ($sec,$min,$hour,$mday,$mon) = localtime($time);
+ printf "%-9s%-8s%s %2d %02d:%02d %s\n",
+ $name,$line,$mo[$mon],$mday,$hour,$min,$host;
+ }
+}