#!/usr/local/bin/rexx

sleep(10)

PARSE ARG tm
IF DATATYPE(tm)<>'NUM' THEN tm=200

DO i=1 TO tm
   '/usr/bin/w >FIFO'
   ima=0; users=""
   IF QUEUED()>0 THEN DO
      PULL .
      PULL .
      END
   DO WHILE QUEUED()>0
      PARSE PULL user tty .
      IF LEFT(tty, 4)=="ttyp" THEN ITERATE
      IF LEFT(tty, 4)=="tty" && DATATYPE(SUBSTR(tty, 4, 1))='NUM' THEN ITERATE
      IF user="tony" THEN EXIT
      IF user="djos" THEN EXIT
      IF user="kostovic" THEN EXIT
      users=users" "user
      IF user="modem" THEN ITERATE
      IF user="flame" THEN ITERATE
      ima=ima+1; 
      END
   SAY time('n')'> Killing 'ima' ('users')'
   IF ima>0 THEN 
      'killall -TERM pppd'
   sleep(1)
END
