[prev in list] [next in list] [prev in thread] [next in thread] 

List:       netatalk
Subject:    Re: [netatalk-admins] not quite 'top' but
From:       Nicolai Langfeldt <janl () math ! uio ! no>
Date:       1997-10-27 10:39:08
[Download RAW message or body]

jon@colossus.cs.wits.ac.za (John Ostrowick) tastet:
> the following is a script i made to show who was logged in.
...

Yes, that's cool.  

However running ps all those times was slow.  Here is my version,
it runs ps only once.  It's for ksh, but everyone has ksh, right?

#!/bin/ksh

runps () {
    STATUS="$(ps axuw)"
    AFPSTATUS=$(print -n "$STATUS" | grep afpd)
    print -n "$STATUS" | head -1
}

case $# in
    1)  runps
        print "$AFPSTATUS" | grep "$1"
        exit 0;;
    0)  :;;
    *)  print "Usage: awho [user]"
        exit 0;;
esac;

runps
print "$AFPSTATUS\n"
print 'total number of users logged on: ' $(print -n "$AFPSTATUS" | wc -l)

print -n 'main afpd status: '
case $AFPSTATUS in
  '')  print DOWN;;
  *)   print up;;
esac

print -n 'atalkd status: '
case $(print -n "$STATUS" | grep atalkd) in
  '')  print DOWN;;
  *)   print up;;
esac

exit 0

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic