#!/bin/rc # write a crlf-terminated string fn netwrite { echo $* | tr \012 \015; echo } # translate a network address fn cslookup { echo $1 | ndb/csquery >[2]/dev/null |tr -d '>' } if (~ $1 -l) { chatty = ' /W' shift } user = `{echo $1 | sed -e 's/@.*//'} if (! ~ $#user 0) { host = `{echo $1 | sed -e s/'^'$user//} } if not { host = $1 } host = `{echo $host | tr -d @} if (~ $#host 0) { if (~ $#user 0) { echo 'finger whom?' >[1=2] exit 'no arguments' } if not { exec whois $user } } # translate the network address for finger x=`{cslookup net!$host!finger} if(~ $#x 0){ echo couldn''''t translate $host >[1=2] exit 'unknown host' } clonefile=$x(1) dialstring=$x(2) # hold the clone file open to keep the connection ours <[4] $clonefile { netdir=`{basename -d $clonefile} ^ / ^ `{cat /fd/4} # write connect string to /net/tcp/N/ctl echo connect $dialstring >$netdir/ctl || exit 'cannot connect' # write the request netwrite $user $chatty >$netdir/data # read and print the answer tr -d \015 < $netdir/data }