#!/usr/local/bin/rexx

trace o

PARSE ARG user
IF user="" THEN user='vana'
PARSE UPPER VAR user uuser .
'echo "Hi, fool. Guess who has just logged on?" > fool.text'

DO FOREVER
   '/usr/bin/w | grep tony >FIFO'
   max=QUEUED()  
   DO i=1 TO max
      PARSE PULL . tty . 
      tty.max=tty
      END 
   IF max>0 THEN DO
      '/usr/bin/w | grep 'user' >FIFO'
      mux=QUEUED()
      IF mux>0 THEN DO
         PARSE UPPER PULL user .
         IF user=uuser THEN 
            DO j=1 TO max
               'write tony 'tty.j' < fool.text'
               END 
         END 
      END
   SLEEP(5)
END 
