[comp.unix.questions] archie

pravin@eniac.seas.upenn.edu (05/16/91)

Is there a way to log on to archie set the mailto, search, etc, do
prog <keyword> and then mail the results back to me.  The only thing
that I will have to do is give <keyword> as the argument to a command.
Probably someone has already done something like this.  If so, I would
appreciate getting it.  Please send e-mail or post here.  I will
summarize/post anything I get!

Thanks!

pravin
--
This program posts news to billions of machines throughout the galaxy.
Your message will cost the net enough to bankrupt your entire planet, and
as a result your species will be sold into slavery. Be sure you know what
you are doing.

fitz@mml0.meche.rpi.edu (Brian Fitzgerald) (05/16/91)

pravin@eniac.seas.upenn.edu writes:
>Is there a way to log on to archie set the mailto, search, etc, do
>prog <keyword> and then mail the results back to me.  The only thing
>that I will have to do is give <keyword> as the argument to a command.
>Probably someone has already done something like this.  If so, I would
>appreciate getting it.  Please send e-mail or post here.  I will
>summarize/post anything I get!

Around the winter solstice of last year Carl Edman of the University of
California, Irvine posted a shell script to comp.unix.shell that does
some of what you want (thanks!).  I modified it to handle the case of
month-day-time type directory entries that occur in the latter six
months of the previous year.  You can redirect the output of this
script to a pipe or a file if you wish.  Here it is:

#! /bin/sh
# Brian P. Fitzgerald
# Rensselaer Polytechnic Institute
#
# original by
# Carl Edman
# University of California, Irvine
#
# usage: archie <regex>
#
echo "prog $1" | rsh quiche.cs.mcgill.ca -l archie "" | awk '
BEGIN {months = "JanFebMarAprMayJunJulAugSepOctNovDec"}
/Host/ { host = $2 }
/Last/ { curm = index(months,$5) ; cury = $6 }
/Location:/ { dir = $2 }
/FILE/||/DIRECTORY/ { if (index($6,":"))
	{year = cury
		if (index(months,$4) > curm) year = cury - 1}
	else year = $6
	printf "%3s %2s %4s %7s /%s:/%s/%s\n",$4,$5,year,$3,host,dir,$7 }
{ next }' - | sort +2nr -3 +0Mr -1 +1nr -2

Lately, I have been using the following "expect" script (Thanks for
creating expect, Don Libes!  Please try not to break "expect" when you
fix TTY security, Dan Bernstein and friends!)

-----
#!/usr/local/bin/expect

# archie

# Log in to the archie index server at McGill University

# Brian P. Fitzgerald
# Department of Mechanical Engineering
# Rensselaer Polytechnic Institute

# expect is available by anonymous ftp from durer.cme.nist.gov as
# /pub/expect.shar.Z and from many other places, such as uunet.

# tcl is available by anonymous ftp from ucbvax.berkeley.edu 
# as /pub/tcl.tar.Z, and from many other places.

set CINTR       \CC
set CSUSP       \CZ

send_user "type ^C to exit, ^Z to suspend\n"

spawn telnet quiche.cs.mcgill.ca
expect	*login:*	{send archie\r}		\
	*unknown*\r*	{exit 1}		\
	*unreachable*	{exit 1}

expect	*archie>*	{send set pager\r}
expect	*archie>*	{send set  maxhits 20\r}
expect	*archie>*	{send set term vt100\r}
expect	*archie>*	{send set sortby time\r}
expect	*archie>*	{send set mailto you@your.edu\r}

interact	$CINTR  {exit 0}		\
		$CSUSP  {exec kill -STOP 0}
-----

These programs have worked satisfactorily for me for a while now, but
comments and suggestions are always welcome.

Brian

-- 
We need to secure as many banks in our computer banks as possible.  We
don't want no one else's help, but yours.  Miller's Comsumer Service