#!/bin/rc # simple gopher client # the function netcat is stolen from the the nc script by some 9front user (aiju?) # how to use: just highlight the file, directory or server you want to # gopher to and send it. You will be taken to your destination. To go # to the root of the gopher server, just send a /. fn netcat { port='' host='' proto=tcp switch($#*){ case 2 host=$1; port=$2 case 3 host=$1; port=$2; proto=$3 case * echo 'usage: nc ipaddr port [proto=tcp]' exit usage } { id=`{read<[0=3]} echo $proto connection is $id echo connect $host^'!'^$port >[1=3] cat /net/$proto/$id/data & cat >/net/$proto/$id/data } <>[3] /net/$proto/clone } fn work { ip=`{echo ''$host'' | ndb/dnsquery | awk '{print $4}'} label ''$host'' echo host: ''$host'' echo ip: $ip # window -m rc -c 'gopher2html '$host' 70 /1|htmlfmt;rc' echo | netcat $ip 70 | sed 's/ //g' | awk '{print NR "\t" $0}'>/tmp/gophersite echo | netcat $ip 70 | sed 's/70 //g' | awk '{print NR "\t" $0}' while(){ file=`{read} switch($file){ case /* echo $file | netcat $ip 70 | sed 's/ //g' | awk '{print NR "\t" $0}'>/tmp/gophersite echo $file | netcat $ip 70 | sed 's/70 //g' | awk '{print NR "\t" $0}' case * echo $file > /tmp/file window -m rc -c 'label `{cat /tmp/file}; G `{cat /tmp/file}' } } } switch($#*){ case 1 host=`{echo $1 | sed 's;gopher://;;g'} work case * echo -n 'gopher host? ' host=`{read} if(~ $#host 0){ echo no host exit } work }