#!/bin/bash # # tip (C) Benjamin Okopnik 2/24/2000 # Some ideas from "mail2web" by Mark A. Hood # Builds text tips into a nicely laid-out Web page. # Change this Web page directory to suit your needs. stem="/home/httpd-data" index="$stem/index.html" clear if [ ! -d $stem ] then echo 'Creating the Archive directory...' mkdir -p $stem fi if [ ! -f $index ] then echo 'Creating the Tip Archive file...' echo 'Tip Archive
'>>$index echo '

Tip Archive

'>>$index echo ''>>$index echo '
SubjectDatePosted by:
'>>$index echo 'Done!' echo echo else if [ $(head -1 $index|grep -c "Tip Archive") -lt 1 ] then clear echo "A \"$index\" file already exists on your system, but it is not" echo "the Tip Archive. Please resolve this problem before continuing." echo echo exit 1 fi fi echo "Tip title (Press 'Enter' to quit):" read title if [ -z "$title" ]; then exit 1; fi tmp="$(mktemp $stem/temp.XXXXXX)" fnm="$(mktemp $stem/temp.XXXXXX)" mcedit $tmp if [ ! -s $tmp ] then rm -f $tmp echo "Aborted: Empty tip file!" exit 1 fi date=$(date "+%H:%M %m/%d/%Y") from="$USER@$HOSTNAME" head -3 $index>>$fnm echo ''"$title"''"$date"''>>$fnm echo ''$from'


'>>$fnm cat $tmp>>$fnm echo '


'>>$fnm tail --lines=$(($(grep -c $ $index)-3)) $index>>$fnm mv $fnm $index rm $tmp clear exit 0