3 # $0 [prog ($1 will be the query)] ([port])
5 [ "$ADDR" = "" ] && ADDR
=127.0.0.1
6 [ "$LOG" = "" ] && LOG
=/tmp
/log.err
7 [ "$PIDF" = "" ] && PIDF
="`mktemp`"
8 [ "$TIMEOUT" = "" ] && TIMEOUT
=10
9 [ "$MAXCON" = "" ] && MAXCON
=1024
12 [ "$port" = "" ] && port
=70
14 if [ "$prog" = "" ]; then
16 echo "Syntax: $0 [prog (\$1 will be the query)] ([port])" >&2
20 tmpd
=`mktemp -t -d .gopher-service.XXXXXX`
21 if [ ! -d "$tmpd" ]; then
23 echo "Cannot create temporary directory, aborting..." >&2
31 while [ -e "$PIDF" ]; do
33 [ $i -gt "$MAXCON" ] && i
=1
37 < "$fifo" nc
-l -q0 -w"$TIMEOUT" "$ADDR" -p "$port" |
(
39 query
="`echo "$query" | cut -f2 -d' '`"
41 "$prog" "$query" 2>> "$LOG"