Hello
I always wanted to have a "/usr/bin/rfc 911" or "/usr/bin/rfc tcp" command,
that gives me easy access without remembering, that the rfcs are somewhere
under /usr/share/doc/RFC/links or /usr/share/doc/doc-rfc/all-included-rfcs
or whereever...
Also I tend to forget the number of the RFC numbers for the most often
used ones (ip/tcp/..., pop3/http11/...).
Therefore I wrote a little perl script that works like described above.
Very simple but very usefull. In case you want to include a script that
needs perl I wrote a little wrapper that checks for perl and if its found
calls the script that translates some names into numbers else just works
for numbers. Both use /usr/bin/sensible-pager and fall back to zless.
bye,
-christian-
--------------------------------- /usr/bin/rfc --------------------
#!/bin/sh -e
if [ -z "`which perl`" ]; then
rfc-flexible.pl $*
else
if [ -z "$1" ]; then
echo "Usage: rfc <number>"
exit 1
fi
P=sensible-pager; if [ ! -x "$P" ]; then P=zless fi
$P /usr/share/doc/RFC/links/rfc$1.txt.gz
fi
e strict;
my($DIR) = "/usr/share/doc/RFC/links";
my(%P) = (
"dns" => \%{ {"nr"=>1034, "off"=>1} },
"ftp" => \%{ {"nr"=>765, "off"=>1} },
"http11" => \%{ {"nr"=>2068, "off"=>1} },
"icmp" => \%{ {"nr"=>792, "off"=>1108} },
"ip" => \%{ {"nr"=>791, "off"=>830} },
"pop3" => \%{ {"nr"=>1939, "off"=>1} },
"requirements" => \%{ {"nr"=>1122, "off"=>1} },
"tcp" => \%{ {"nr"=>793, "off"=>1075} },
"udp" => \%{ {"nr"=>768, "off"=>26} },
);
if ((not defined @ARGV) or ($#ARGV!=0)) {
printf("Usage: rfc <keyword>|<number>\n\n".
"Where keyword is one of:\n".
"%s\n",
join(" ", map { "$_ " } sort keys %P));
exit(1);
}
my($PAGER) = "sensible-pager";
$PAGER = "zless" if ("`which sensible-pager`" eq "");
if (defined $P{$ARGV[0]}) {
system("$PAGER +".$P{$ARGV[0]}{"off"}." $DIR/rfc".$P{$ARGV[0]}{"nr"}.".txt.gz"
);
} else {
system("$PAGER $DIR/rfc".$ARGV[0].".txt.gz");
}