Get a pdf man page

For PC type software that runs under some PC opsys.

Get a pdf man page

Postby Doug Coulter » Wed Jan 02, 2019 10:01 am

Now and then you just have to Read the Fscking Manual. I don't like man to do that with, at least on the linux mint/mate I run here - a window I have to scroll around in, no way to search that I know of, random organization of the pages etc, just make it too clunky for my taste. However, it's not really hard to convert a man page to a .pdf, which, while it's that hated Adobe format, has readers everywhere that make it look nice - and it's for cryin out loud, searchable. n Since this will never embed actual code in a .pdf, most of the issues with the crappy design of the format aren't a worry here.

This came up yet again today (I already had this tip in my own personal version of PHPBB I keep around for things I doubt anyone else is interested in - or am embarrassed to admit I don't have in my wetware automatically) when I read of a "bug" in wget that stores passwords you maybe weren't expecting it to.

This was news to me as I've never used it in a situation where one was asked of me - or included in some copypasta example to get some little toy for supporting, say, NGINX or Perl. So I go RTFM and just about hurl my cookies looking for how you'd even put in a password. It's there, to be sure, but finding it, that's another thing, I didn't want to spend all day.

So this little gem - complete with no error checking at all...makes a pdf file out of a man page in whatever directory your terminal is in, and then you can use any pdf reader to look at it in a nicer font and have it be searchable - it took less time to get this script into my laptop from a reference here and run it to find "password" than I'd already spent trying and failing to find it in the man page as normally accessed. So, here it is. If you want to add error checking...be my guest and please post back with the better version. All this does is assume that if there are two arguments, one of them is the "man page section number". And no other checking is done.... It'll probably just fail if you mess up the command line. I hope.

I put this in my /home/doug/bin directory so it'll be on the path, and of course, you have to chmod +x this to make it runnable. I call mine man2pdf.

Code: Select all
#!/bin/bash
#man2pdf script
#  $# is number of args
# echo "arg1 is $1 arg 2 is $2"
# fairly cheesy existence test and assume
# args are reasonable - no error checking
if [ $2 ]
then
FILE=($2.ps)
else
FILE=($1.ps)
fi
echo "file: $FILE"
man -t $1 $2 >> $FILE
ps2pdf $FILE 
rm $FILE



For example, man2pdf 5 crontab works and will make crontab.pdf in the current directory. Leaving out the number also works for the default manpage section.

Now, I could really use a way to transport posts from one PHPBB instance to another - I do like having my local copy for backup if nothing else, and well, things like code blocks or attachments don't' just copy paste over.
Posting as just me, not as the forum owner. Everything I say is "in my opinion" and YMMV -- which should go for everyone without saying.
User avatar
Doug Coulter
 
Posts: 3515
Joined: Wed Jul 14, 2010 7:05 pm
Location: Floyd county, VA, USA

Re: Get a pdf man page

Postby Bob Reite » Sat Jan 05, 2019 2:01 am

OK where do I get "ps2pdf"? Oh!! Install ghostscript. Slick!
The more reactive the materials, the more spectacular the failures.
The testing isn't over until the prototype is destroyed.
User avatar
Bob Reite
 
Posts: 142
Joined: Wed Nov 11, 2015 1:02 pm
Location: Wilkes Barre / Scranton PA

Re: Get a pdf man page

Postby Doug Coulter » Tue Jan 08, 2019 12:48 pm

Yeah, I really like this one. It's sloppy in that there's no error checking, but not much crazy happens with a typo either (now, if someone else is on your system...that's another story of course).
Even systemD now almost makes sense after a few of the snootier out there told me to RTFM, stupid. And finally telling me WHICH manual....NOW it's at least not hurting me too badly, though I'm not sure they've fixed the semi-documented issue where if it tries to start something that might take a few seconds...it can time out, and try again...without killing the old process first, which eventually does start, running you out of memory etc and then crashing, which I discovered trying to run Conky (a fancy perf monitor). Somewhere there's a file you can edit that I forget the path of...that can change that, but it had the look/feel of "until the next update to systemd" about it.

Anyway, since you'd never guess...
There are a few man pages that I got for me - note the crucial "how to write service files" one with the name you'd just about never figure out on your own. Yeah, RTFM the only man page I've seen with underscores in the name... (Old man yells at sky ;~)

You might find this one handy, in other words: sysd_service_file.pdf as well as systemctl and journalctl manual pages.

Sent you a PM, Bob.
Posting as just me, not as the forum owner. Everything I say is "in my opinion" and YMMV -- which should go for everyone without saying.
User avatar
Doug Coulter
 
Posts: 3515
Joined: Wed Jul 14, 2010 7:05 pm
Location: Floyd county, VA, USA


Return to PC

Who is online

Users browsing this forum: No registered users and 10 guests