Shell script accesses online man pages (needs nohup)

How to do things, solutions, recipes, tutorials
Post Reply
Message
Author
User avatar
fitzhugh
Posts: 217
Joined: Fri 16 Jun 2006, 02:58
Location: Berkeley

Shell script accesses online man pages (needs nohup)

#1 Post by fitzhugh »

really only of interest to those who do not know how to write shell scripts and are learning how to use linux from the command line. Will be too obvious for others, I suspect.

This is a super simple two line script to use a much larger online collection of man pages in instead of the usual incomplete local collection.

As it covers things not available in puppy, and requires an active internet connection, it should not replace the man command, so I named it mana instead of man because I'm used to typing man, so it is close, and is fast to type, but name it whatever you like, of course. You can also change the browser to whatever you wish by simply swapping the word "dillo" for another, like "opera", but dillo is good for this because it opens quickly and will appear on the top of other windows, while opera or others already open will open the page in the frame currently used by the open page and not bring it to the forground. You can also change the url to use whatever online man page collection you wish by replacing the URL, being sure to put $@ where the search term belongs in the URL.

We have a situation in puppy: we use busybox, which replaces a huge number of normal linux functions with one single multipurpose tool. This is hidden from the user because it is aliased to the names of the commands it replaces, but sometimes it does come into awareness because it uses only a subset of the functionality of some commands in order to be smaller, a reasonable trade off. However, we also have the busybox man page (notice singular) instead of man pages for each command, and this really is minimal documentation. I often want the full man page for a command, even if it leaves me with command envy for the options not available in the busybox version. I need to be able to read all the sections, especially the examples, for commands I'm learning. There are also other holes in our man pages... they are just not all there (can't think of the examples I've encountered, but it has happened a number of times: just get the Welcome to Puppy/Puppy Help page when hoping to get a man page because it isn't there.

Here is a two line script you can add to /usr/local/bin as, say, mana:

Code: Select all

#!/bin/sh
exec nohup dillo "http://www.penguin-soft.com/penguin/man?q=$@&section=ALL&action=man" &
Note that there are ONLY two lines, but it may wrap on your screen:

Code: Select all

#!/bin/sh
is one line

Code: Select all

exec nohup dillo "http://www.penguin-soft.com/penguin/man?q=$@&section=ALL&action=man" &
is the second.

Create the file in any text editor, save it to /usr/local/bin/mana, and change the permissions to make it executable by either typing

Code: Select all

chmod a+x /usr/local/bin/mana
or selecting permissions after right-clicking on it in rox

r__hughes
Posts: 359
Joined: Thu 13 Apr 2006, 04:14
Location: Montreal, Canada

#2 Post by r__hughes »

Very very nice - but I got a hiccup on the 'nohup' part so I had to leave that one word out of the command.

billstclair
Posts: 106
Joined: Mon 27 Feb 2006, 01:23
Location: Upstate New York
Contact:

#3 Post by billstclair »

"nohup" is not part of Puppy, as shipped. The nohup source compiled without error, for me, however. I created a tiny dotpup, available in the "Dotpups" section of http://s3.amazonaws.com/puppy/index.html .

I think nohup should be part of the standard Puppy. It's tiny. It's useful. It's part of every other Linux and Unix I've ever used.

r__hughes
Posts: 359
Joined: Thu 13 Apr 2006, 04:14
Location: Montreal, Canada

#4 Post by r__hughes »

Thank you Bill - I just downloaded & installed your 'nohup' dotpup and I can now use fitzhugh's script as is - without fear of hangups - tip of the hat to both of you.

User avatar
fitzhugh
Posts: 217
Joined: Fri 16 Jun 2006, 02:58
Location: Berkeley

#5 Post by fitzhugh »

Ah, sorry about the nohup! He's correct that it is not a default part of puppy, and since it is actually the very first thing I install I forgot it was not part of puppy. Of course, the reason it is the first thing I install is because otherwise I keep forgetting it isn't there and trying to use it :)

What nohup does, if you are not familiar, is allow you to run a command or application or whatever and release it, so that the terminal window that started it can shut down without killing what was started from it (if nohup was used in starting it). Adding an & after the command puts it in the background after starting, so you can continue using the terminal for other things. I never use nohup without &, though there are probably reasons. I just got sick of starting apps from terminals, then forgetting I'd done so and killing the app when I closed the terminal.

I've edited my .bashrc file so that it aliases most of my common apps to
nohup <app> &
so I can start them from command line without bothering to type nohup.

raffy
Posts: 4798
Joined: Wed 25 May 2005, 12:20
Location: Manila

Another howto

#6 Post by raffy »

I've edited my .bashrc file so that it aliases most of my common apps to "nohup <app> &" so I can start them from command line without bothering to type nohup.
Hmm, pls don't laugh when people ask you how to do this one. :) It will be a big help. Thanks.
Puppy user since Oct 2004. Want FreeOffice? [url=http://puppylinux.info/topic/freeoffice-2012-sfs]Get the sfs (English only)[/url].

User avatar
fitzhugh
Posts: 217
Joined: Fri 16 Jun 2006, 02:58
Location: Berkeley

#7 Post by fitzhugh »

no, I'm in no position to laugh! I ask questions nonstop here :)

If anyone is interested just let me know and I'll explain in detail. Otherwise I'll write up a tutorial for the wiki on .bashrc, nohup, dtach (kinda similiar to nohup but more advanced, not as advanced as screen), and whatever else fits - that will be some time though.


One thing to note about nohup: it essentially takes a process and spews whatever is returned from it to a file called nohup.out rather than to the terminal. This means you will find a nohup.out file in the directory from which you called nohup. This can be tossed, not sure if it is overwritten or appended to, having never thought to check before. It can be useful in seeing what, if anything, the program returned though.

r__hughes
Posts: 359
Joined: Thu 13 Apr 2006, 04:14
Location: Montreal, Canada

#8 Post by r__hughes »

I am definitely interested in this - but I guess I could wait for for a wiki.
Please post back or otherwise advise when the wiki is done -should I hold my breath? :wink:

Post Reply