LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 06-28-2014, 09:49 AM   #1
dijetlo
Senior Member
 
Registered: Jan 2009
Location: RHELtopia....
Distribution: Solaris 11.2/Slackware/RHEL/
Posts: 1,491
Blog Entries: 2

Rep: Reputation: Disabled
Internal Documentation Script


This is a script that looks through your file system for "index.html" files and outputs them in a format that the firefox web browser can import as a bookmark file, giving you access to some of the web based documentation installed with the packages that make up your linux distro (so it should be relevant to what's installed on your machine).
You just copy it, paste it into your favorite text editor, save the file as "something.sh" and make it executable.
From a terminal:
Code:
 
chmod 740 something.sh 
./something.sh
It should create a file in your home directory, internal_bookmarks.html, that you can import into firefox as a bookmark folder named "Internal Documentation".
A couple of notes:
TESTING: It's only been tested on Slackware 64 multi-lib current, though it should have no problem running on any system that has a bash shell. If you test it and it works, do me a favor and post your distro and that it works. If it doesn't work, post your distro and the error message and we'll see if we can get it to work.
Web Pages:It only pulls index.html pages. If you want all html pages go to the function Grinder and change "index.html" to "*.html" in the script but friend... that's liable to be a lot of pages.
Bookmark Names: It pulls the name of the individual bookmarks from the html of the page, specifically. "<title> What the guy titled it</title>" produces a bookmark named "what the guy titled it".
Icons: I'm a Slackware zombie, we don't do icons.
Improvements: If anybody can think of any, I'd greatly appreciate it.
Code:
#!/bin/bash
# As always, this script is free to a good home, comes with no 
# warranties, whatsoever. If it turns you into a newt...well, perhaps
# you'll get better.
# a script for indexing localhost index.html files and converting the index
# into a firefox importable bookmarks html file called internal_bookmarks.html in the user home 
# directory. Firefox imports it as it's own folder named "internal documentation"
#
# date in the bookmarking world is the number of seconds since the epoch (midnight, 1970)

TICK=$(date +%s)
STICK="$HOME/internal_bookmarks.html"
# formatting the boilerplate

function Top_Plate(){
echo '<!DOCTYPE NETSCAPE-Bookmark-file-1>'> $STICK
echo '<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8">'>> $STICK
echo '<TITLE>Bookmarks</TITLE>'>> $STICK
echo '<H1>Bookmarks Menu</H1>'>> $STICK
echo '<DL><p>'>> $STICK 
echo '<DT><H3 ADD_DATE='$TICK' LAST_MODIFIED='$TICK' >Internal Documentation</H3>' >> $STICK
echo '<DL><p>'>> $STICK
}

# closing off the DL tags

function Bottom_Plate() {
CTR=$(grep -c '<DL>' $STICK)
while [ $CTR -gt 0 ];do
echo '</DL><p>' >> $STICK
CTR=$[$CTR-1]
done
}

# Creating the bookmarks, creates a tmp file called "bookmarks.tmp" and then delete it.
# If you want ALL html files bookmarked, change index.html in the first line
# to *.html

function Grinder(){
find / -iname index.html 2>/dev/null 1> bookmarks.tmp
while read bookmark; do
  TITLE=$(grep -i -o -P '(?<=<title>).*(?=</title>)' $bookmark )
  echo "<DT><A HREF=file://"$bookmark" ADD_DATE= "$TICK" ICON= > "$TITLE" </A>">> $STICK
done <bookmarks.tmp
rm bookmarks.tmp
}

Top_Plate
Grinder
Bottom_Plate
exit 0
Final note: The bookmarks are dependent on the rights of the user. I've suppressed the error output but believe me, when you run this thing straight from the command line you'll get a lot of "permission denied" errors (unless you're root and if you are..tsk, tsk) so run it for each user on your system as that user or it will create bookmarks the user doesn't have rights to access.

Enjoy.

Last edited by dijetlo; 06-28-2014 at 09:52 AM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to prevent internal DOS using for loop script ? sunzeal Linux - Newbie 9 07-05-2013 05:55 AM
500 Internal Server Error - CGI Script sp0oon Fedora 1 11-11-2012 11:06 AM
Internal server error (Premature end of cgi script) cbtshare Linux - Server 16 02-07-2011 03:17 PM
500 Internal Server Error/Premature end of script headers baruah Linux - Software 1 04-01-2006 05:10 PM
FAQ: Internal Server Error / Premature End of Script Header / MS-DOS Carriage Return rebel Red Hat 2 04-30-2005 03:11 PM


All times are GMT -5. The time now is 01:57 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration