In both of the following, some statements have been made into comments
in an attempt to make them work. For the first of these, the attempt
was successful. Both scripts have permissions 0755, which corresponds
to chmod a+rx o-w.
As a reminder, all my scripts worked fine on a prior Web host's server.
A simple script that works displays the current date and time as
specified in RFC 822:
#!/bin/ksh
# Display current date-time in RFC 822 format
# print 'Content-type: text/html'
# print ''
now=$(date -R)
/bin/echo $now
================================================
A complex script that does not work is supposed to display a list all
the HTML files in my space on the Web servers in UNIX ls format but
formatted as a Web page:
#!/bin/ksh
# Create index file, listing files
typeset -L restline
# fromwhere=${HTTP_REFERER%/*} # Web site (directory, not page)
\rm -f *.fidx # get rid of old files (if any)
savedir=$(pwd) # save old directory
# cd .. # get into directory with HTML files
# cd ~ # get into directory with HTML files
\rm -f index_list.html
ls -ld *.html | grep -v 'get_index.shtml' | grep -v 'lrwxr' >
$savedir/raw.fidx
# save only HTML files, but not caller of this file
ls -ld CA_review/*.html | grep -v 'lrwxr' >> $savedir/raw.fidx
# include CA_review directory
ls -ld Canada_trip/*.html | grep -v 'lrwxr' >> $savedir/raw.fidx
# include Canada_trip directory
ls -ld cooking/*.html | grep -v 'lrwxr' >> $savedir/raw.fidx
# include cooking directory
ls -ld editorials/*.html | grep -v 'lrwxr' >> $savedir/raw.fidx
# include editorials directory
ls -ld frauds_n_hoaxes/*.html | grep -v 'lrwxr' >> $savedir/raw.fidx
# include frauds_n_hoaxes directory
ls -ld garden/*.html | grep -v 'lrwxr' >> $savedir/raw.fidx
# include garden directory, exclude diary subdirectory
ls -ld garden/diary/*.html | grep -v 'lrwxr' >> $savedir/raw.fidx
# include garden diary directory
ls -ld internet/*.html | grep -v 'lrwxr' >> $savedir/raw.fidx
# include internet directory
ls -ld malaprops/*.html | grep -v 'lrwxr' >> $savedir/raw.fidx
# include malaprops directory
ls -ld PGP/*.html | grep -v 'lrwxr' >> $savedir/raw.fidx
# include PGP directory
ls -ld quips/*.html | grep -v 'lrwxr' >> $savedir/raw.fidx
# include quips directory
ls -ld SocSec/*.html | grep -v 'lrwxr' >> $savedir/raw.fidx
# include SocSec directory
ls -ld taxes/*.html | grep -v 'lrwxr' >> $savedir/raw.fidx
# include taxes directory
ls -ld unemployed/*.html | grep -v 'lrwxr' >> $savedir/raw.fidx
# include unemployed directory
ls -ld UPS_sucks/*.html | grep -v 'lrwxr' >> $savedir/raw.fidx
# include UPS directory
cd $savedir # return to original directory
awk '{ print $5, $6, $7, $8, $9 }' raw.fidx > temp.fidx
# extract size, date, and file-name
touch list.fidx
while read size date1 date2 date3 fname; do
print -n '<tr><td><a href="'$fname'">'$fname'</a></td>' >> list.fidx
print -n '<td align="right">'$size'</td>' >> list.fidx
print '<td>'$date1 $date2 $date3'</td></tr>' >> list.fidx
done < temp.fidx
print '</table>' >> list.fidx
print ' ' >> list.fidx
print '<p align="center">This index was created' \
$(date +'%A, %e %b %Y at %T %Z') >> list.fidx
cat front.tidx list.fidx back.tidx > index.fidx
# print 'Content-type: text/html'
# print ''
while read indexline; do
print $indexline
done < index.fidx
\rm -f *.fidx # get rid of temp files
Where front.tidx is a text file containing the HTML <Head> section with
the beginning of the <Body> section and back.tidx is a text file
containing the HTML for the page's footer with the </body> and </html>
markup.