#!/usr/local/bin/perl # # build a table of links from the stuff found here. # the file "lectures" gives the name of the lecture directories in # the right order # cgi.cs.rpi.edu doesn't seem to have the right application mime types, # so we need to force links to go to www.cs.rpi.edu $server="http://www.cs.rpi.edu/~hollingd/opsys-spring2005"; # start with the header print `cat header`; open(F,"lectures") || die $!; @lecs = ; close(F); chomp(@lecs); print"
\n"; for ($i=0;$i<=$#lecs;$i++) { mkrow($i,$lecs[$i]); } printf("
TopicAdobe PDFLinks
\n"); printf("
\n"); printf("
\n"); sub mkrow { my($num,$dir) = @_; if ((! -f "$dir/$dir.pdf") && ( -f "$dir/$dir.PDF")) { system("mv $dir/$dir.PDF $dir/$dir.pdf"); } if ($num%2) { printf("\n"); #F5DEB3 } else { printf("\n"); } $name = getname($dir); printf(" $name\n"); if (-f "$dir/$dir.pdf") { printf(" $dir.pdf\n"); } else { printf("  \n"); } printf(" %s\n",getlinks($dir)); printf("\n"); } sub getlinks { my($dir) = $_[0]; if (! -f "$dir/Links") { return " "; } my(@lines); my($l,$r); open(F,"$dir/Links") || die $!; @lines = ; close(F); chomp(@lines); my($i); for ($i=0;$i<=$#lines;$i++) { $l = $lines[$i]; if (! ($l =~ /^ *$/)) { $r .= $l . "
\n"; } } chomp($r); if ($r) { return($r); } else { return(" "); } } sub getname { my($dir) = $_[0]; if (! -d $dir) { return ""; } if (! -f "$dir/Name") { return ""; } my($line); $line = `cat $dir/Name`; chomp($line); return($line); }