From:	CSBVAX::MRGATE!info-vax-RELAY@KL.SRI.COM@SMTP 10-JUL-1988 05:14
To:	ARISIA::EVERHART
Subj:	A handy program


Received: from unocss.unl.edu ([129.93.1.11]) by KL.SRI.COM with TCP; Wed, 29 Jun 88 09:55:36 PDT
Received: by unocss.unl.edu (4.12/4.7)
	id AA08702; Wed, 29 Jun 88 11:55:54 cdt
Date: Wed, 29 Jun 88 11:55:54 cdt
From: fritz@unocss.unl.edu (Tim Russell)
Message-Id: <8806291655.AA08702@unocss.unl.edu>
To: info-vax@kl.sri.com
Subject: A handy program

Here's a handy program I use every once in a while...

=======================  Cut Here =====================================

$! WATCHFOR.COM - Watch in the background for a friend to log on.
$!
$!    This program is meant to be spawned in a background process from a
$! symbol such as this:
$!
$!        WATCHFOR :== SPAWN/NOWAIT/INPUT=NL:/NOLOG @WATCHFOR
$!
$! And can then be invoked as a normal command, the first parameter being
$! the username to watch for (DEFINED aliases are acceptable) and the
$! second, optional, parameter being the interval between checks in
$! seconds.  When the given user logs on, the program SENDs a message to
$! the user who ran it and exits.  If your site doesn't have Jnet commands,
$! the SEND can be replaced with a
$!
$!    $ WRITE SYS$OUTPUT "^G^G''p1' just logged on!!!"
$!
$! This program is placed into the public domain.  Feel free to hack it
$! beyond recognition.   Flames/comments/neat changes to:
$!
$!        Internet: fritz@fergvax.unl.edu
$!        Bitnet:   CONSLT32@UNOMA1
$!        UUCP:     {backbones}!unocss!fritz
$!
$!============================================================================
$!
$! Find out who's running us..
$ user = f$edit(f$getjpi("", "USERNAME"),"COLLAPSE")
$!
$! How often should we check? Default is every ten seconds.
$!
$ if p2 .eqs. "" then p2 = "10"
$!
$! Get real username if they gave us a DEFINED one
$!
$ realname = f$trnlnm(p1)
$ if realname .eqs. "" then realname = p1
$!
$! Be nice to the users...
$ set process/priority=3
$!
$! Loop till they log on or we die...
$!
$ assign NLA0: sys$output
$ assign NLA0: sys$error
$ loop:
$ wait 00:00:'p2'
$ show users 'realname'
$ if $severity .nes. 1 then goto loop
$!
$! They logged on - notify the user
$!
$   set process/priority=4
$   p1 = f$extract(0,1,p1) + f$edit(f$extract(1,f$length(p1)-1,p1), "LOWERCASE")
$   send 'user' "''p1' just logged on!!!    (''f$extract(12,8,f$time())')"
$ exit

---------------------------------+--------------------------------------------
 Tim Russell, Computer Operator  | Internet: fritz@fergvax.unl.edu
 Campus Computing                | Bitnet:   OPER06@UNOMA1
 University of Nebraska at Omaha | UUCP:     {ihnp4}!unocss!fritz
---------------------------------+-------------------------------------------
