home *** CD-ROM | disk | FTP | other *** search
- #! /bin/csh -f
-
- ########################################################################
- #
- # Copyright 1992 by the Massachusetts Institute of Technology.
- # All rights reserved.
- #
- # Developed by the Intelligent Engineering Systems Laboratory
- # M.I.T., Cambridge, Massachusetts.
- #
- # THIS SOFTWARE IS PROVIDED "AS IS", AND M.I.T. MAKES NO REPRESENTATIONS
- # OR WARRANTIES, EXPRESS OR IMPLIED. By way of example, but not
- # limitation, M.I.T. MAKES NO REPRESENTATIONS OR WARRANTIES OF
- # MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE OR
- # THAT THE USE OF THE LISCENCED SOFTWARE OR DOCUMENTATION WILL NOT
- # INFRINGE ANY THIRD PARTY PATENTS, COPYRIGHTS, TRADEMARKS OR OTHER
- # RIGHTS.
- #
- # The name of Massachusetts Institute of Technology or M.I.T. may
- # NOT be used in advertising or publicity pertaining to distribution
- # of the software. Title to copyright in this software and any
- # associated documentation shall at all times remain with M.I.T.,
- # and USER agrees to preserve the same.
- #
- # Permission to use, copy, modify, and distribute this material
- # for any purpose and without fee is hereby granted, provided that
- # the above copyright notice and this permission notice appear in
- # all copies.
- #
- ########################################################################
-
-
-
-
- #look for environment variable for dumping directory......
-
- setenv | grep RFC_DIR >&! /dev/null
- if ( $status ) then
- setenv RFC_DIR `pwd`
- echo "You have not specified a directory to place the"
- echo "rfc index and retrieved rfc files. These will be"
- echo "placed in $RFC_DIR."
- echo "To specify a directory set the RFC_DIR environment variable"
- echo ""
- echo ""
- endif
-
- ##################################################################
- # archive site
- #
- # CHANGE THIS VARIABLE TO ACCESS A DIFFERENT ARCHIVE SITE!!!
- #
- ##################################################################
-
- set rfc_archive = ftp.nisc.sri.com
-
- #Various and sundry other variables
-
- #set index_name = rfc-index-title-first.txt
- set index_name = rfc-index.txt
- set local_dir = $RFC_DIR
- set remote_dir = rfc
- set rfcnum = ()
- set resp = y
-
- # this is another hack that I should fix someday....
- set charlist = abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ
-
- # Look for local copy of rfc index.
-
- if ( ! -e $RFC_DIR/$index_name ) then
- echo "Local copy of rfc index not found in $RFC_DIR."
- echo "(Forget to set your RFC_DIR environment variable?)."
- echo "This command will force a sync."
- setenv SYNC_ME 1
- else
- setenv SYNC_ME 0
- endif
-
- # Usage statement
-
- if $#argv == 0 then
- echo "Usage: get_rfc [options] [rfc-num list]"
- echo "options"
- echo " -i interactive file request"
- echo " -t search for internet topic"
- echo " -s sync local index with archive site"
- goto DONE
- endif
-
- #process topic and sync before processing interactive
-
- # If there is no index we do a sync. First
- # scan arglist and delete sync requests. Then
- # prepend sync option. It works anyway.....
-
- if $SYNC_ME then
- set cpy = ( $argv )
- set cpy1 = ""
- while ( $#cpy > 0 )
- switch ( $cpy[1] )
-
- case "-s":
- breaksw
-
- default:
- set cpy1 = "$cpy1 $cpy[1]"
- endsw
- shift cpy
- end
-
- set cpy1 = "-s $cpy1"
- set argv = ( $cpy1 )
- endif
-
- set cpy = ( $argv )
-
- FIRST_ARG_LOOP:
- while ( $#cpy > 0 )
- switch ( $cpy[1] )
-
- case "-t":
- shift cpy
- set again = y
- while ( $again == y )
- echo -n "Enter topic: "
- set resp = "$<"
- if ( "$resp" != "" ) then
- egrep -i "$resp" $RFC_DIR/$index_name
- endif
- set again = "n"
- echo -n "Search again? (y/n) [n]: "
- set again = $<
- if ( "$again" != "" ) then
- set again = `expr substr "$again" 1 1`
- endif
- end
- breaksw
-
- case "-s":
- shift cpy
- echo "Syncing local index with copy at $rfc_archive"
- set file_list = $index_name
- goto DO_FETCH
- breaksw
-
- default:
- shift cpy
- endsw
- end
-
- set cpy = ( $argv )
-
- SECOND_ARG_LOOP:
- while ( $#cpy > 0 )
- switch ( $cpy[1] )
-
- case "-s":
- case "-t":
- shift cpy
- breaksw
-
- case "-i"
- shift cpy
- echo -n "Get RFC Number(s): "
- set rfcnum = ( $< )
-
- default:
- set num_list = ( $cpy $rfcnum )
-
- while( $#num_list > 0 )
- set not_num = `expr index $num_list[1] $charlist`
- if ( $not_num ) then
- echo Bad rfc number $num_list[1]. EXIT.
- exit 1
- endif
-
- shift num_list
- end
- set rfcnum = ( $cpy $rfcnum )
- break
- endsw
- end
-
-
- FETCH:
- #
- # if there's nothing in the rfcnum variable, quit.
- #
-
- if ( $#rfcnum == 0 ) goto DONE
-
- #
- # Build the file list from the index number list
- #
-
- set file_list = ()
- foreach f_index ( $rfcnum )
- set file_list = ( $file_list rfc$f_index.txt )
- end
-
- echo "Getting the following files from from $rfc_archive;"
- foreach file ( $file_list )
- echo $file
- end
-
- echo -n "Continue? y/n [y]: "
- set resp = $<
- if ( "$resp" == "n" ) then
- echo ABORT
- goto DONE
- endif
-
-
- #
- # Do the fetch!!
- #
-
- DO_FETCH:
-
- ftp -n -i << +
- open $rfc_archive
- user anonymous culbert@iesl.mit.edu
- cd $remote_dir
- lcd $local_dir
- bin
- mget $file_list
- bye
- +
-
- # If this was a forced sync, return to the argument processing loops.
-
- if $SYNC_ME then
- setenv SYNC_ME 0
- goto FIRST_ARG_LOOP
- endif
-
- #
- # List the files locally to give a little confidence that all went well...
-
- pushd $local_dir >&! /dev/null
- ls -l $file_list
- popd >&! /dev/null
-
- #
- # BYE!!!!
- #
-
- DONE:
-
- exit 0
-
-