#!/usr/local/bin/rexx

verbose=0
pwd='/home/tony/'

TRACE OFF

PARSE ARG email

IF email='' THEN DO
   pwd'bin/ffinger dcosic@jagor.srce.hr'
   pwd'bin/ffinger kbahun@jagor.srce.hr'
   EXIT
   END

width=79

IF verbose>0 THEN 
   SAY copies('-', width)

'/bin/cat 'pwd'test/'email' >FIFO'
IF rc<>0 THEN DO
   '/bin/touch 'pwd'test/'email
   END 

last='(no data)'

DO WHILE QUEUED()>0
   PARSE PULL last
   END 

IF verbose>0 THEN DO
   SAY 'Checking login for:' email
   SAY copies('-', width)
   END

new=""
'/usr/bin/finger 'email' >FIFO'
lines=QUEUED()
DO i=1 TO lines
   PARSE PULL red
   PARSE VAR red . ' login ' when ' on ' terminal ' from ' place .
   IF when<>"" THEN DO
      new=when' logged on from: 'place
      END
   END
new =STRIP(new)
last=STRIP(last)

IF new<>"" THEN 
   IF new<>last THEN DO
      CALL Lineout pwd'test/'email, new
      last=new
      END 

IF verbose>0 THEN DO
   SAY "Last logon:" last
   SAY copies('-', width)
   END
