Search Members Help

» Welcome Guest
[ Log In :: Register ]

Mini-ITX Boards Sale, Fanless BareBones Mini-ITX, Bootable 1G DSL USBs, 533MHz Fanless PC <-- SALE $200 each!
Get The Official Damn Small Linux Book. DSL Market , Great VPS hosting provided by Tektonic
 

[ Track this topic :: Email this topic :: Print this topic ]

reply to topic new topic new poll
Topic: mkindexhtml.sh with nweb httpd, Handy tool by me and small httpd combo.< Next Oldest | Next Newest >
Zucca Offline





Group: Members
Posts: 524
Joined: Feb. 2006
Posted: Nov. 29 2006,21:17 QUOTE

All right!

I think everybody can can find out the idea from source:
Code Sample
#!/bin/bash

# mkindexhtml.sh v0.1.4b - Creates index.html file containing links to files it finds.
# handy with nweb httpd. http://www-128.ibm.com/developerworks/eserver/library/es-nweb.html
# Copyright (C) 2006 Zucca (Zucca@IRCnet, ICQ#: 66768853, [EMAIL=zuccavondille@gmail.com]zuccavondille@gmail.com[/EMAIL])

# 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.
# http://www.gnu.org/licenses/gpl.txt

if [ "$1" == "--help" ]
then
 echo -e "USAGE: mkindexhtml.sh <dir> <column count> [noprompt]"
 echo -e "       mkindexhtml.sh --help\n"
 echo -e "mkindexhtml.sh creates a file named index.html to <dir>."
 echo -e "index.html will contain all visible files (except index.html, nweb.log and directories) with links to them"
 echo -e "<column count> determines maxium of \$FILEs on a single line."
 echo -e "\nUseful with nweb httpd. http://www-128.ibm.com/developerworks/eserver/library/es-nweb.html"
 echo -e "\n   mkindexhtml.sh v0.1.4b (C) (GPL) Zucca@IRCnet, ICQ#:66768853\n"
 exit 0
fi

if [ -z $2 ]
then
 echo -e "USAGE: mkindexhtml.sh <dir> <column count> [noprompt]"
 echo -e "       mkindexhtml.sh --help\n"
 exit 1
fi

if [ -f "$1/index.html" ] && [ "$3" != "noprompt" ]
then
  echo "You already have previous index.html."
 rm -i $1/index.html
 if [ -f "$1/index.html" ]
 then
   echo -e "Aborted. Left original index.html untouched."
   exit 1
 fi
elif [ -f "$1/index.html" ] && [ "$3" == "noprompt" ]
then
 rm -f $1/index.html
fi

let "COLC=1"

echo -ne "<HTML>\n\n<HEAD>\n<TITLE>Directory index created by mkindexhtml.sh</TITLE>\n</HEAD>\n\n<BODY>\n<NOBR>" >> $1/index.html

for FILE in `ls $1`
do

 if [ "$FILE" != "index.html" ] && [ "$FILE" != "nweb.log" ] && [ ! -d "$FILE" ]
 then

   let "COLC=$COLC+1"

   if [ "$COLC" -gt "$2" ]
   then
     echo "<BR>" >> $1/index.html
     let "COLC=1"
   elif [ "$COLC" -gt "2" ]
   then
     echo -n "| " >> $1/index.html
   fi
 
   echo -ne "<A HREF=\"$FILE\">$FILE</A>\n" >> $1/index.html
 fi
done

echo -ne "\n<PRE>mkindexhtml.sh v0.1.4b created by Zucca@IRCnet, ICQ#:66768853\n Licenced under GNU General Public License.</PRE>\n\n</BODY>\n\n</HTML>" >> $1/index.html


Nice? But needs few things to be even more neat: nweb httpd and one line of extra code to run both, the script and the server:
Code Sample
killall nweb 2> /dev/null; ./mkindexhtml.sh <dir to share> <max cols> && <path to nweb> <port> <dir to share>


You can make it more simple by creating a sctipt from it like this (change paths!):
Code Sample
#!/bin/bash

killall nweb 2> /dev/null; /home/dsl/mkindexhtml.sh $1 5 && /home/dsl/nweb/nweb 8000 $1

See? Only 'directory to share' must be specified. Neat. :)

What's the use? Well you can rapidly share your files without much configration.
And changing shared directory isn't hard if you use the 'launch script'.
Here's my server running it.

D0h! Again I forgot that there's a statement such as case. Oh well. Until next update...


--------------
Do you have it? - http://dy.fi/mak
Back to top
Profile PM WEB ICQ MSN 
Zucca Offline





Group: Members
Posts: 524
Joined: Feb. 2006
Posted: Dec. 17 2006,20:41 QUOTE

Update:

Code Sample
#!/bin/bash

VERS="v0.2.2.2b"

LICENCE="
# mkindexhtml.sh - Creates index.html file containing links to files it finds.
# handy with nweb httpd. http://www-128.ibm.com/developerworks/eserver/library/es-nweb.html
# Copyright (C) 2006 Zucca (Zucca@IRCnet, ICQ#: 66768853, Zucca@dive.to)

# 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.
# http://www.gnu.org/licenses/gpl.txt
"
# NEW feature:
# if you place .index.header or .index.footer files
# to the same dir where mkindexhtml.sh will create it's
# index.html then it will incluce those files in index.html.
# Header will be displayed before filelisting and
# footer will be displayed arfer.

HTMLSOURCEFOOTER="
As you seemed enough curious to look for html source, here's some details about mkindexhtml.sh:

Licence:
$LICENCE

In a simple way: It's free.
Some versions I make are not posted to public.
- Why?
Because I want to publish only good versions of this program.
Anyway you can still contact me if you want your copy of mkindexhtml.sh.

Currently I publish mkindexhtml.sh only at Damn Small Linux board:
http:///damnsmalllinux.org/static/act-ST/f-23/t-16279"/

if [ "$1" == "--help" ]
then
 echo -e "USAGE: mkindexhtml.sh <dir> <column count> [noprompt]"
 echo -e "       mkindexhtml.sh --help\n"
 echo -e "mkindexhtml.sh creates a file named index.html to <dir>."
 echo -e "index.html will contain all visible files (except index.html, nweb.log and directories) with links to them"
 echo -e "<column count> determines maxium of \$FILEs on a single line."
 echo -e "\nUseful with nweb httpd. http://www-128.ibm.com/developerworks/eserver/library/es-nweb.html"
 echo -e "\n   mkindexhtml.sh $VERS (C) (GPL) Zucca@IRCnet, ICQ#:66768853\n"
 exit 0
fi

if [ -z $2 ]
then
 echo -e "USAGE: mkindexhtml.sh <dir> <column count> [noprompt]"
 echo -e "       mkindexhtml.sh --help\n"
 exit 1
fi

if [ -f "$1/index.html" ] && [ "$3" != "noprompt" ]
then
  echo "You already have previous index.html."
 rm -i $1/index.html
 if [ -f "$1/index.html" ]
 then
   echo -e "Aborted. Left original index.html untouched."
   exit 1
 fi
elif [ -f "$1/index.html" ] && [ "$3" == "noprompt" ]
then
 rm -f $1/index.html
fi

let "COLC=1"

echo -ne "<HTML>\n\n<HEAD>\n<TITLE>Directory index created by mkindexhtml.sh</TITLE>\n</HEAD>\n\n<BODY>\n" >> $1/index.html

if [ -f "$1/.index.header" ]
then
 cat $1/.index.header >> $1/index.html
fi

echo -ne "\n<NOBR>\n" >> $1/index.html

for FILE in `ls $1`
do

 if [ "$FILE" != "index.html" ] && [ "$FILE" != "nweb.log" ] && [ ! -d "$FILE" ]
 then

   echo -ne "<A HREF=\"$FILE\">$FILE</A>\n" >> $1/index.html
   
   if [ ! "$COLC" -eq "$2" ]
   then
     echo -n "| " >> $1/index.html
   fi

   let "COLC=$COLC+1"

   if [ "$COLC" -gt "$2" ]
   then
     echo "<BR>" >> $1/index.html
     let "COLC=1"
   fi
 
 fi
done

UDATE=`date`

if [ -f "$1/.index.footer" ]
then
 cat $1/.index.footer >> $1/index.html
fi

echo -ne "
</NOBR><PRE>Index updated: $UDATE
mkindexhtml.sh $VERS created by Zucca@IRCnet, ICQ#:66768853
Licenced under GNU General Public License.</PRE>

</BODY>" >> $1/index.html

echo -ne "\n\n<!--\n$HTMLSOURCEFOOTER\n\n//-->\n\n</HTML>" >> $1/index.html


--------------
Do you have it? - http://dy.fi/mak
Back to top
Profile PM WEB ICQ MSN 
1 replies since Nov. 29 2006,21:17 < Next Oldest | Next Newest >

[ Track this topic :: Email this topic :: Print this topic ]

 
reply to topic new topic new poll
Quick Reply: mkindexhtml.sh with nweb httpd

Do you wish to enable your signature for this post?
Do you wish to enable emoticons for this post?
Track this topic
View All Emoticons
View iB Code