From: djpadz@orion.oac.uci.edu (Dj Padzensky)
Subject: A direct shell interface to gopher information
Newsgroups: comp.infosystems.gopher
Date: 9 Nov 92 19:29:36 GMT

Awhile back, I was wanting to log some information that was available
on a gopher server to a file at regular intervals.  Problem was,
though, there was really no automated way to do this.  So, here's a
perl script that will allow one to get text information from a
bookmark in your .gopherrc file, and send it directly to stdout.

The syntax is simple.  If you have defined a bookmark (which
references text information - type 0) called "mybookmark", then type:

go-fer mybookmark

To list the bookmarks you can use with this script, type:

go-fer -l

The bookmarks are case insensitive.

Feel free to email comments to me, or flames to /dev/null...

--Dj Padzensky
UCI Office of Academic Computing
[djpadz@uci.edu]

--------------------------- CUT SOMEWHERE AROUND HERE -------------------------

#!/bin/sh
# This is a shell archive (shar 3.32)
# made 11/09/1992 19:28 UTC by djpadz@hydra.acs.uci.edu
# Source directory /sx/oac5/dcs/djpadz
#
# existing files WILL be overwritten
#
# This shar contains:
# length  mode       name
# ------ ---------- ------------------------------------------
#   1531 -rwx------ go-fer
#
if touch 2>&1 | fgrep 'amc' > /dev/null
 then TOUCH=touch
 else TOUCH=true
fi
# ============= go-fer ==============
echo "x - extracting go-fer (Text)"
sed 's/^X//' << 'SHAR_EOF' > go-fer &&
X#!/usr/bin/perl
X
X# go-fer 1.0 (9-NOV-92) - By Dj Padzensky - [djpadz@uci.edu]
X
X$bmfile = "$ENV{'HOME'}/.gopherrc";
X$bm = "@ARGV";
X$bm =~ tr/A-Z/a-z/;
Xchop($hostname = `/bin/hostname`);
X
Xif ($bm eq "") {
X  print STDERR 
X    "\nsyntax: $0 (bookmarkname | -l)\n-l will list valid bookmarks\n\n";
X  exit(1);
X}
X
Xprint "\nBookmarks I can go fer:\n" if $bm eq "-l";
X
Xopen(BMFILE,$bmfile);
Xwhile (<BMFILE>) {
X  $type = $1 if /Type=(.*)/;
X  $name = $1 if /Name=(.*)/;
X  $name =~ tr/A-Z/a-z/;
X  $path = $1 if /Path=(.*)/;
X  $host = $1 if /Host=(.*)/;
X  $port = $1 if /Port=(.*)/;
X  print "  $name\n" if ($bm eq "-l") && (/Name/) && ($type==0);
X  last if ($bm eq $name) && /Port/;
X}
Xclose(BMFILE);
X
Xif ($bm eq "-l") { print "\n"; exit(0); }
Xif ($bm ne $name) { print STDERR "Couldn't find $bm\n"; exit(1); }
Xif ($type != 0) { 
X  print STDERR "Can only support text sockets (type 0) so far..."; exit(1);
X}
X
X$AF_INET=2;
X$SOCK_STREAM=1;
X$sockaddr = 'S n a4 x8';
X($name,$aliases,$proto) = getprotobyname('tcp');
X($name,$aliases,$port) = getservbyname($port,'tcp') unless $port =~ /^\d+$/;;
X($name,$aliases,$type,$len,$thisaddr) = gethostbyname($hostname);
X($name,$aliases,$type,$len,$thataddr) = gethostbyname($host);
X$this = pack($sockaddr,$AF_INET,0,$thisaddr);
X$that = pack($sockaddr,$AF_INET,$port,$thataddr);
Xsocket(S,$AF_INET,$SOCK_STREAM,$proto) || die $!;
Xbind(S,$this) || die $!;
Xconnect(S,$that) || die $!;
Xselect(S);
X$|=1;
Xselect(STDOUT);
X
Xprint S "$path\n";
Xwhile(<S>) {
X  chop;
X  chop;
X  print "$_\n" unless ($_ eq ".");
X}
Xclose(S);
SHAR_EOF
$TOUCH -am 1109112792 go-fer &&
chmod 0700 go-fer ||
echo "restore of go-fer failed"
set `wc -c go-fer`;Wc_c=$1
if test "$Wc_c" != "1531"; then
	echo original size 1531, current size $Wc_c
fi
exit 0
--
_______________________________________________________________________________
Internet: djpadz@uci.edu            | #include <std_disclaimer.h>
America Online: DjPadz              | #include "funny_quote.h"