|
|
ru.linux- RU.LINUX --------------------------------------------------------------------- From : Andy Shevchenko 2:465/192 29 Oct 2001 17:53:47 To : All Subject : Re: RFC -------------------------------------------------------------------------------- .RFC-X-Complaints-To: news@serv.smile.org.ua .RFC-NNTP-Posting-Date: 30 Oct 2001 14:55:18 GMT .RFC-X-Priority: 3 .RFC-X-MSMail-Priority: Normal .RFC-X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 This is a multi-part message in MIME format. ------=_NextPart_000_0252_01C160D4.F32D4C90 Content-Type: text/plain; charset="koi8-r" Content-Transfer-Encoding: 8bit "Pavel Vasilyev" <Pavel_Vasilyev@p19.f3003.n5020.z2.fidonet.org> wrote in message news:1004396608@p19.f3003.n5020.z2.fidonet... > Hаpод, а на каком сайте находится полное собpание RFC ? Посмотри на приатаченый скриптец -- пригодится :) (Будет у тебя, если захочешь :)) -- With Best Regards, Andy Shevchenko mailto:andy@smile.org.ua ------=_NextPart_000_0252_01C160D4.F32D4C90 Content-Type: text/plain; name="rfcat.txt" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="rfcat.txt" : #########################################################################= # # Shellscript: rfcat - print RFC text # Version : 2.3 # Author : Heiner Steven <heiner.steven@odn.de> # Date : 2001-04-25 # Category : Web # SCCS-Id. : @(#) rfcat 2.3 01/07/26 #########################################################################= # # Description # o Prints the text of an internet standard (RFC: "Request For # Comments") to standard output. Tries to locate the RFC locally, # and retrieves it otherwise direcly from the Web. # o Each RFC text file can optionally be cached after first retrieval # # Note # Needs the following non-standard programs: # wget #########################################################################= # PN=3D`basename "$0"` # Program name VER=3D'2.3' # A program to accept an URL as command line argument, retrieves it, and # prints the results to standard output : ${GETURL:=3Dwget} : ${GETURLFLAGS=3D"-O- -q"} # may be empty : ${COMPRESS:=3Dgzip} : ${COMPRESSFLAGS=3D-f} # may be empty # The local directory all RFCs are contained within : ${RFCDIR:=3D/usr/local/share/rfc} # The base WWW URL for all RFCs RFC_BASE_URL=3Dhttp://www.ietf.org # The URL of the "INDEX" page RFC_INDEX_URL=3D$RFC_BASE_URL/iesg/1rfc_index.txt # A template for an RFC URL. The string '${no}' will be replaced by the # RFC's number RFC_BY_NUMBER_TEMPL=3D"$RFC_BASE_URL/rfc/rfc\${no}.txt" #########################################################################= Usage () { echo >&2 "$PN - print RFC text, $VER (stv) usage: $PN [-fc] rfcspec [...] -c: create a local copy of the file, if it does not exist already -f: force retrieval of the file from the Web An rfcspec can be a RFC number (e.g. 2100), or the symbolic name \"INDEX\". The RFC is searched locally (RFCDIR=3D$RFCDIR). If this was not successful, $PN will retrieve it from $RFC_BASE_URL." exit 1 } Msg () { for MsgLine do echo "$PN: $MsgLine" >&2 done } Fatal () { Msg "$@"; exit 1; } #########################################################################= # rfc2path - convert RFC specification to local path name of file #########################################################################= rfc2path () { [ $# -eq 1 ] || Fatal "INTERNAL ERROR: rfc2path needs one argument" _rfcspec=3D$1; shift case "$_rfcspec" in INDEX) _url=3D$RFC_INDEX_URL;; *) no=3D$_rfcspec eval _url=3D"$RFC_BY_NUMBER_TEMPL"; esac echo $RFCDIR/rfc$_rfcspec } #########################################################################= # rfc2url - convert RFC specification to URL of file #########################################################################= rfc2url () { [ $# -eq 1 ] || Fatal "INTERNAL ERROR: rfc2url needs one argument" _rfcspec=3D$1; shift case "$_rfcspec" in INDEX) _url=3D$RFC_INDEX_URL;; *) no=3D$_rfcspec eval _url=3D"$RFC_BY_NUMBER_TEMPL"; esac echo "$_url" } #########################################################################= set -- `getopt cfh "$@"` || Usage [ $# -lt 1 ] && Usage # "getopt" detected an error CacheFile=3Dfalse ForceRetrieval=3Dfalse while [ $# -gt 0 ] do case "$1" in -c) CacheFile=3Dtrue;; -f) ForceRetrieval=3Dtrue;; --) shift; break;; -h) Usage;; -*) Usage;; *) break;; # First file name esac shift done [ $# -lt 1 ] && Usage errors=3D0 for rfc do rfc=3D`echo "$rfc" | sed 's/^00*//g'` # remove leading zeroes # # Search RFC locally # file=3D`rfc2path "$rfc"` if [ -n "$file" ] && [ $ForceRetrieval =3D false ] then for ext in "" .gz .Z .z .txt.gz .txt.Z .txt.z do [ -r "$file$ext" ] || continue case "$ext" in "") cat "$file$ext" ;; *.gz ) gunzip -c "$file$ext";; *.Z ) zcat "$file$ext";; *.z ) unpack "$file$ext";; esac [ $? -eq 0 ] || errors=3D`expr $errors + 1` continue 2 # Next RFC done fi # # No local file. Try to retrieve the RFC via URL # url=3D`rfc2url "$rfc"` if [ -n "$url" ] then # Get the RFC using the Web. # XXX: This page could be cached locally using # ... | tee $RFCDIR/... if [ $CacheFile =3D true ] then # Retrieve file, and create a local copy. # Ignore keyboard signals, because they could cause the local copy # to be incomplete trap '' 1 2 3 13 15 $GETURL $GETURLFLAGS "$url" | tee "$file" trap 1 2 3 13 15 if [ -s "$file" ] then "$COMPRESS" $COMPRESSFLAGS "$file" else rm -f "$file" # remove empty file fi else $GETURL $GETURLFLAGS "$url" fi [ $? -ne 0 ] && errors=3D`expr $errors + 1` fi done exit $errors ------=_NextPart_000_0252_01C160D4.F32D4C90-- --- Microsoft Outlook Express 6.00.2600.0000 * Origin: Smile Club (2:465/192@fidonet) Вернуться к списку тем, сортированных по: возрастание даты уменьшение даты тема автор
Архивное /ru.linux/12169ba53d850.html, оценка из 5, голосов 10
|