From: cameron@spectrum.cs.unsw.oz.au (Cameron Simpson)
Newsgroups: aus.aarnet
Subject: Re: better use of `prog' on archie ...
Keywords: archie prog search aftp ftp batch email
Date: 9 Oct 92 06:33:43 GMT
Reply-To: cameron@spectrum.cs.unsw.oz.au (Cameron Simpson)
Distribution: aus
Organization: CS&E Computing Facility, Uni Of NSW, Oz

I wrote:
|	archie> mailprog cameron@cs.unsw.oz.au
|	archie> prog thing1
|	searching... blah blah blah ...
|	sending results of search to cameron@cs.unsw.oz.au
| 
| and so forth. I _don't_ take the last few screens; I almost always use `mail'
| to send off the complete query so I can peruse it easily. A pger isn't what I
| want; I want a terse way to do the query.

David Keegal suggests:
| I would certainly suggest grabbing and installing the xarchie program if
| you're on the Internet (that means AARNet in Australia at the minute) and
| running the X window system (X11).  It has buttons and menus and scroll
| bars and all the other nice things you expect of a graphical application.

Tried this once. Slow, and I _hate_ using humungous X clients for simple tasks.
(And my screwy colour scheme rendered it difficult to see, let alone use...)

Someone (sorry, I've misplaced your name) suggested the email interface and
an `rc' script. Since I haven't got around to installing `rc' here I
translated it to `sh', and now use it all the time. Let's face it, you don't
want to wait around anyway.

I append the script below. Very useful. A quick mod to my mail system
autodelivers the results to a directory with entries named after the query.

| The only problem I found with it is that you can't query the `packages'
| database (well, I couldn't anyway), and that the `ftp' button doesn't
| ask you for a local directory to put the files in (so I just used
| regular ftp(1) from a shell normally).

I also append my `aftp' script which is a simple wrapper for ftp which smooths
many things, making batch fetches fairly easy.
	- Cameron Simpson
	  cameron@cs.unsw.oz.au

"The engine purrs beneath me with a purpose, ready for the pleasure of my hand
 upon the throttle."		- Peter Smith

#!/bin/sh
#
# Cut here and feed through /bin/sh.
#
# Contents:
#	prog	look up things from archie via email
#	aftp	easier ftp access
#

sed 's/^X//' > prog <<'EOF-//fuligin/1/cameron/bin/prog'
X#!/bin/sh
X#
X# Query archie via email.
X#
X
Xcmd=`basename "$0"`
X
Xarchie=archie@archie.au
X
Xcase $# in
X    0)	while [ -t 0 ] && echo -n "$cmd> "
X	      read pattern
X	do
X	    echo "prog $pattern"
X	done
X	;;
X    *)	for pattern
X	do
X	    echo "prog $pattern"
X	done
X	;;
Xesac | m "$archie"
EOF-//fuligin/1/cameron/bin/prog

sed 's/^X//' > aftp <<'EOF-//fuligin/1/cameron/bin/aftp'
X#!/bin/sh
X#
X# Anonymous ftp to a host.
X#
Xcmd=`basename "$0"`
Xusage="Usage: $cmd [-[abiv]] [-d workdir] [-l login] [-p password] \\
X		host [commands...]
X	-a	ASCII mode by default.
X	-b	Binary mode by default.
X	-d	Specify working directory.
X	-i	Interactive after performing commands.
X	-l	Specify login name.
X	-p	Specify password.
X	-v	Verbose."
X
Xt=/tmp/aftp.$$
Xd=$t
Xiflag=
Xvflag=
Xbadargs=
Xhost=
Xconv=binary
Xlogin=anonymous
Xpassword="
Xpassword $USER@cs.unsw.oz.au"
Xwhile :
Xdo
X    case "$#,$1" in
X	0,*)	echo "$cmd: missing hostname" >&2
X		badargs=1
X		break ;;
X	1,-[dl]) echo "$cmd: missing argument to $1" >&2
X		badargs=1
X		;;
X	*,-a)	conv=ascii ;;
X	*,-b)	conv=binary ;;
X	*,-d)	d=$2; shift ;;
X	*,-l)	login=$2; shift; password= ;;
X	*,-p)	password="
Xpassword $2"; shift ;;
X	*,-i)	iflag=1 ;;
X	*,-v)	vflag=-v ;;
X	*,-*)	echo "$cmd: bad argument \"$1\"" >&2
X		badargs=1
X		;;
X	*,*)	host=$1; shift; break ;;
X    esac
X    shift
Xdone
X
X[ -n "$badargs" ] && { echo "$usage" >&2; exit 2; }
X
X[ -d "$d/." ] || mkdir "$d" || exit $?
X
Xhere=`pwd`	|| exit $?
X
Xcd "$d"		|| exit $?
XHOME=`pwd`	|| exit $?
Xexport HOME
X
X[ "x$d" != "x$t" ] || cd "$here" || exit $?
X
Xinit=prompt
Xcase $# in
X    0)	iflag=1 ;;	# no commands, interactive by default
X    *)	for arg
X	do init="$init
X		 $arg"
X	done ;;
Xesac
X
Xecho >"$HOME/.netrc" "machine $host
Xlogin $login $password
Xmacdef init
X$init
X$conv
X"
Xchmod 600 "$HOME/.netrc"
X
X[ -n "$iflag" ] || exec </dev/null	# cancel interaction
Xftp $vflag "$host"
X
X[ "x$d" != "x$t" ] || { rm "$d/.netrc" && rmdir "$d" ; }
EOF-//fuligin/1/cameron/bin/aftp

exit 0
Newsgroups: aus.aarnet