#!/bin/rc
if(! ~ 1 $#*){
echo 'usage: 9talk/motd addr' >[1=2]
exit usage
}
addr=$1
libdir=$home/lib/9talk
idfile=$libdir/$addr.id
motdfile=$libdir/$addr.motd
mkdir -p $libdir
if(test -r $idfile)
cmd='SKIP '^`{cat $idfile}
if not
cmd='HIST'
{echo $cmd; echo QUIT} | aux/dial -e $addr >.motd$pid
id=`''{tail -1 .motd$pid}
motd=`''{grep '^MOTD ' .motd$pid | tail -1 | tail +5c}
rm .motd$pid
echo -n $id>$idfile
if(! ~ $"motd '')
echo -n $motd>$motdfile
cat $motdfile