Created
July 22, 2022 19:15
-
-
Save petrsnd/00d0b4bec4de76a03f7c0819a138e457 to your computer and use it in GitHub Desktop.
Fetch and RFC and make it printable as a booklet
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Dan Peterson | |
# Threw out Matt's old stuff and now I just use pdfbook2 to generate the booklet | |
if test -t 1; then | |
YELLOW='\033[1;33m' | |
RED='\033[1;31m' | |
NC='\033[0m' | |
fi | |
EnsureProgramExists() | |
{ | |
local prgm=`which $1` | |
if [ ! -x "$prgm" ]; then | |
>&2 echo -e "${RED}Unable to find the $1 program${NC}" | |
exit 2 | |
fi | |
} | |
if [ -z $1 ]; then | |
echo "Print the resulting PDF 2-sided (landscape), fold it in half, and staple" | |
echo "the centerfold. Walla, you've got a handy booklet" | |
echo "Usage: $0 rfc_number" | |
exit 0 | |
fi | |
echo "$1" | grep -q [^[:digit:]] | |
if [ $? -ne 1 ] ; then | |
>&2 echo -e "${RED}You must enter the number of an RFC${NC}" | |
exit 2 | |
fi | |
EnsureProgramExists wget | |
EnsureProgramExists pdfbook2 | |
#url="http://www.ietf.org/rfc/rfc$1.txt" | |
url="https://www.ietf.org/rfc/rfc$1.txt.pdf" | |
outfile="rfc$1.pdf" | |
bookfile="rfc$1-book.pdf" | |
wget -O $outfile "$url" | |
pdfbook2 $outfile | |
echo -e "\n${YELLOW}PDF: $outfile\nBooklet: $bookfile${NC}" | |
echo -e "\nPrint double-sided. Flip on the long edge when printing!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment