WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: man script  (Read 5043 times)

Offline jpeters

  • Restricted
  • Hero Member
  • *****
  • Posts: 1017
man script
« on: February 04, 2009, 06:08:44 AM »
Here's a great little script by Barry Kauler that I changed to work with Netrik for reading manuals.
First it searches through /usr/share/doc, and if nothing is found loads  http://linux.die.net/man/${1}.

example:

Code: [Select]
man help

This brings up the "Getting Started With Tiny Core Linux" doc. Type "q" to quit

I just submitted netrik.tce, netrik.tcl  (44K....lightning fast!), and here's a link to the script:

apps/man][removed due to policy]apps/man

Offline jpeters

  • Restricted
  • Hero Member
  • *****
  • Posts: 1017
Re: man script
« Reply #1 on: April 13, 2009, 05:31:42 AM »
It seems die.net has changed it's search functions, so that now it's necessary to include the manual number,  eg "linux.die.net/man/<number>/$1"   This seems really stupid, since now a script won't work unless you can guess what the number is.  "1" will work for many, so that's better than nothing.  :'(


Offline mikshaw

  • Sr. Member
  • ****
  • Posts: 368
Re: man script
« Reply #2 on: April 13, 2009, 10:06:11 AM »
that stinks...it means my script won't fully work either.  It will at least still work for local pages, though, provided you have netrik and man2html
Code: [Select]
manserver="http://linux.die.net/man"
mandir="/home/shared/reference/man_pages"

[ -n "$1" ] || exit
page="$mandir/$1"

for num in 1 2 3 4 5 6 7 8; do
if [ -r "$page.$num.gz" ]; then
zcat "$page.$num.gz" | man2html | netrik -
exit
elif [ -r "$page.$num" ]; then
man2html "$page.$num" | netrik -
exit
fi
done

if [ ! -r "$page.html" ]; then
  wget --dns-timeout=7 "$manserver/$1" -O "$page.html"
  if [ "$?" == 0 ]; then
  sed -i '/<link\ rel.*$/d' "$page.html"
  else rm -f "$page.html" && exit
  fi
fi
exec netrik "$page.html"

I guess I'll need to cut out that second part for the time being.
Ideally I'd like to find a server that has formatted man pages, but no luck so far.

Offline tobiaus

  • Suspended
  • Hero Member
  • *****
  • Posts: 599
Re: man script
« Reply #3 on: April 13, 2009, 11:20:11 AM »
i don't suppose you could put a php script up somewhere, that took the old query and then redirected to the proper new url.

Offline jpeters

  • Restricted
  • Hero Member
  • *****
  • Posts: 1017
Re: man script
« Reply #4 on: April 13, 2009, 04:11:53 PM »
A simple workaround is add another variable, so if it isn't in /man/1 you can try something else.
Probably 1 or 8 will get most of them.  For my posted script, edit line 67.  So "man 1 vim" and
"man 8 ldconfig".   

Code: [Select]
67  netrik http://linux.die.net/man/${1}/${2} 

Offline tobiaus

  • Suspended
  • Hero Member
  • *****
  • Posts: 599
Re: man script
« Reply #5 on: April 13, 2009, 05:28:28 PM »
perhaps you could modify it to download each one to /tmp, then cat them all into a single html file, and load the entire thing in netrik.

Offline jpeters

  • Restricted
  • Hero Member
  • *****
  • Posts: 1017
Re: man script
« Reply #6 on: April 13, 2009, 06:42:56 PM »
perhaps you could modify it to download each one to /tmp, then cat them all into a single html file, and load the entire thing in netrik.

I'm looking for instant info.......TM@ snap computing.......off YOUR server.   :)    (ie, no downloading nutin.....)

Note: I know, text browsers will probably be declared illegal at some point....worse even than ad-block. 
« Last Edit: April 13, 2009, 06:48:49 PM by jpeters »

Offline tobiaus

  • Suspended
  • Hero Member
  • *****
  • Posts: 599
Re: man script
« Reply #7 on: April 13, 2009, 09:58:26 PM »
i love text browsers... as an option. i love text apps in general. links is great. thank you for adding elinks.