Skip to main content

man2pdf Convert unix manpage to PDF

#!/bin/bash

#############################################################################
# #
# man2pdf #
# a simple bash script to convert a man page to pdf #
# #
# Copyright (C) 2003-2004 Trond Aasan #
# #
# 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 2 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 #
# #
# If you find this useful in any way, or if you find a bug, #
# feel free to e-mail me. #
# #
# Trond Aasan #
# http://www.aasan.org/ #
# #
#############################################################################

# $Id: man2pdf,v 1.6 2004/01/23 18:35:41 trondaas Exp $

MAN=$(which man)
if [ -z "$MAN" ]; then
echo "man executable not found in path" >&2
exit 1;
fi

GROFF=$(which groff)
if [ -z "$GROFF" ]; then
echo "groff executable not found in path" >&2
exit 1;
fi

GS=$(which gs)
if [ -z "$GS" ]; then
echo "gs executable not found in path" >&2
exit 1;
fi

USAGE="Usage: $0 [options] [outfile]
Options:
-n SECTION man section
-h Print this help message

If no section is specified, use first hit.

If outfile is not specified, write output to .
.pdf in
current directory.
"

unset MANSECT

while getopts 'n:h' opt; do
case $opt in
n )
export MANSECT="$OPTARG"
;;
h )
echo "$USAGE"
exit
;;
\? )
exit 1
;;
* )
echo "Error"
exit 1
;;
esac
done

shift $(($OPTIND - 1))

if [ -z "$1" ]; then
echo "$USAGE"
exit 1
fi

infile=$("$MAN" -w -- "$1") || exit $?

if [ -z "$MANSECT" ]; then
AWK=$(which awk)
if [ -z "$AWK" ]; then
echo "awk executable not found in path. Will not guess man"\
"section" >&2
else
BASENAME=$(which basename)
if [ -z "$BASENAME" ]; then
echo "basename executable not found in path. Will not guess man"\
"section" >&2
else
basename=$("$BASENAME" "$infile")
section=$(echo "$basename" | "$AWK" -F . \
"/$(echo "$1" | tr . '\.')\.([0-9a-zA-Z])(\.gz)?$/{print \$2}")
fi
fi
fi

case "$infile" in
*.gz | *.Z)
CAT=$(which zcat)
;;
*.bz)
CAT=$(which bzcat)
;;
*.bz2)
CAT=$(which bz2cat)
;;
*)
CAT=$(which cat)
;;
esac

if [ -z "$CAT" ]; then
exit 1
fi

if [ -n "$2" ]; then
outfile="$2"
else
if [ -n "$section" ]; then
outfile="$1.$section.pdf"
else
outfile="$1.pdf"
fi
fi

"$CAT" -- "$infile" | "$GROFF" -t -E -Tps -mandoc -ma4 \
| "$GS" -q -sDEVICE=pdfwrite -sOutputFile="$outfile" -dNOPAUSE -dBATCH -sPAPERSIZE='a4' -


[close]

Comments

Popular posts from this blog

Cisco Command "Auto secure"

Cisco Command "Auto secure" In today's article, I'm going to quickly inform you about the Privileged EXEC command named "auto secure". Network administrators (like you) use the "auto secure" command to secure the management and forwarding planes of a router. Another way of saying it is, CCNAs use this command to secure a router by disabling common IP services which can be exploited by attackers to initiate network attacks. When the command is typed on a router, it takes the user (ccna) through a command line-interface (CLI) semi-interactive session (which is also known as the AutoSecure dialogue). Below is the command's syntax: auto secure [management | forwarding] [no-interact | full] [ntp | login | ssh | firewall | tcp-intercept] As you can see, the command can use several "optional" keywords: management - This (optional) keyword is used to only secure the management plane of a router. forwarding - This (optional) keyword is used to
How to install kismet on MacBook, Mac OS X 10.5.6 Leopard How to installed and run kismet. cd /tmp svn co https://www.kismetwireless.net/code/svn/trunk kismet-devel cd kismet-devel ./configure sudo make install Edit kismet config file like: sudo vim /opt/local/etc/kismet.conf and change the following two lines: a.) suiduser=Your_Username_For_Mac b.) source=darwin,en1,airport_extreme Run kismet and enjoy! sudo kismet

What's the difference between 802.11a, 802.11b, and 802.11g?

What's the difference between 802.11a, 802.11b, and 802.11g? The first difference is that 802.11a uses the 5GHz radio frequency (RF) spectrum while 802.11g and 802.11b share the 2.4GHz spectrum. Therefore 802.11a will not interfere with 802.11g or 802.11b. Since 802.11a uses the 5GHz spectrum, it will have less distance capabilities due the physical nature of electromagnetic radiation. 802.11b and 802.11g use an RF spectrum that allows for 3 non-interfering channels (in North America). 802.11a uses a wider spectrum that allows for 12 non-interfering channels which will be 23 non-interfering channels with soon to be released standard. The idea of non-interfering (or non-overlapping) channels allows more wireless users to be concentrated in an area without having to share the transmission medium. 802.11b, while sharing the same 2.4GHz frequency spectrum as 802.11g, has lower transmission rates and different modulation techniques than 802.11g. For a discussion of transmission ra