18 juin 2008

Des RFC sous la main

C'est lors d'une discussion avec Kbok qu'est apparue l'envie de disposer des RFC comme on dispose des pages de man. Voici donc un petit script shell pour faire le boulot:


#!/bin/bash

# (C) 2008, Arnaud Bellec [arnaud.bellec at gmail dot com]
# (C) 2008, Henri Doreau [henri.doreau at gmail dot com]
# (FUCK) 2008, le mec qui bloque wget sur son site

# This program is free software; you can redistribute it and/or modify

# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.

DIRNAME=_rfc

# Storage
if [ ! -d $DIRNAME ]
then
mkdir $DIRNAME
fi

# We look for an existent file, else we'll download and process it
if [ -z $1 ]
then
echo "No argument supplied!"
echo "Usage : $0 [number of requested RFC]"
else
file="rfc"`echo $1`".txt"
if [ -f $DIRNAME/$file ]
then
over $DIRNAME/$file
else
wget -U "tralala" -q http://www.faqs.org/ftp/rfc/rfc$1.txt -O $DIRNAME/$file
sed '1,32d' -i $DIRNAME/$file
sed -e 's/<[^>]*>//g; /</N;' -i $DIRNAME/$file
fi
fi


Bon alors effectivement la license prend autant de place que le script mais l'idée est là! Il manque une commande sed (ou autre) pour la conversion des caractères spéciaux du HTML.
L'utilisation est trivial, vous pouvez rendre le script executable:

chmod u+x rfc.sh

et créer l'alias suivant dans votre .bashrc:

alias "rfc"="~/rf.sh"

Vous n'avez ensuite qu'à le lancer :

rfc 1035

et il se comporte à peu près comme le man!
En espérant qu'il vous serve!!

A part ça la première version beta de mon Rarping est sortie aujourd'hui. N'hésitez pas à y jeter un oeil et me renvoyer vos commentaires, idées, patches etc...

Aucun commentaire: