#!/bin/sh #--------------------------------------------------------------------- # Script to create HTML file listing movies retrieved by squid # Written by Arron Cusimano, Oct 2000 # Intended to be run by cron on daily basis # version 0.3 #--------------------------------------------------------------------- # setup some variables rand=a$RANDOM$RANDOM$RANDOM xurl=b$RANDOM$RANDOM$RANDOM htmlout=/home/booth/public_html/auto/cached-mpeg.php #--------------------------------------------------------------------- # Write a short perl script to a temp dir so we can run it later echo "#!/usr/bin/perl" > /tmp/$xurl echo "# xurl, script to extract couple fields from squid log" >> /tmp/$xurl echo "# output in html format" >> /tmp/$xurl echo "while (<>) {" >> /tmp/$xurl echo " @field=split();" >> /tmp/$xurl echo " \$size=\$field[4];" >> /tmp/$xurl echo " \$url=\$field[6];" >> /tmp/$xurl echo " print \"
Size: \$size Filename: \",\$url,\"
\n\";" >> /tmp/$xurl echo "}" >> /tmp/$xurl chmod u+x /tmp/$xurl #---------------------------------------------------------------------- # Write the actual html page out # first the header echo "Selected Movies!
" > $htmlout # then the content grep video.mpeg /var/log/squid/acce* | /tmp/$xurl > /tmp/$rand grep video.x-ms-asf /var/log/squid/acce* | /tmp/$xurl >> /tmp/$rand grep video.x-msvideo /var/log/squid/acce* | /tmp/$xurl >> /tmp/$rand grep video.msvideo /var/log/squid/acce* | /tmp/$xurl >> /tmp/$rand grep video.quicktime /var/log/squid/acce* | /tmp/$xurl >> /tmp/$rand cat /tmp/$rand | sort -n -k 2 -r | uniq >> $htmlout rm /tmp/$rand rm /tmp/$xurl # then the footer echo "" >> $htmlout