I have a CGI that reads a random text file and spits it back to whatever calls it. I am trying to call it from a web page as an include or exec. any help would be appreciated.
the cgi works fine when called in the browser as a url, here: http://66.186.192.77/cgi-bin/quotes/quotemaster.cgi? but when I embed it in the HTML it won't display. if I look at the source that comes back I see something like: <div align="center" class="quotesHeader">Quotes From the Edge</div> <font color="#FFFFFF" size="1" face="Arial"> [an error occurred while processing this directive] </font> here are the two methods I have tried: 1) as a include in a shtml file: <div align="center">Quotes From the Edge</div> <font color="#FFFFFF" size="1" face="Arial"> <!--#include virtual="http://66.186.192.77/cgi-bin/quotes/quotemaster.cgi"--> </font> 2) as an exec in an shtml file <div align="center">Quotes From the Edge</div> <font color="#FFFFFF" size="1" face="Arial"> <!--#exec cgi="http://66.186.192.77/cgi-bin/quotes/quotemaster.cgi?"--> </font> the cgi compiles fine and I am using Strict. here is the actual cgi I created: #!/usr/bin/perl -w use strict; use CGI; use CGI::Carp qw(fatalsToBrowser); use constant BUFFER_SIZE => 4_096; use constant QUOTE_DIRECTORY => "../../httpdocs/quotes"; my $q = new CGI; my $buffer = ""; my $quote = random_file( QUOTE_DIRECTORY, '\\.(txt)$' ); my( $type ) = $quote =~ /\.(\w+)$/; print "Content-type: text/html\n\n"; local *QUOTE; open QUOTE, QUOTE_DIRECTORY . "/$quote" or die "Cannot open file $quote: $!"; read QUOTE, $buffer, BUFFER_SIZE; close QUOTE; print $buffer; # close QUOTE; # Takes a path to a directory and an optional filename mask regex # Returns the name of a random file from the directory sub random_file { my( $dir, $mask ) = @_; my $i = 0; my $file; local( *DIR, $_ ); opendir DIR, $dir or die "Cannot open $dir: $!"; while ( defined ( $_ = readdir DIR ) ) { /$mask/o or next if defined $mask; rand ++$i < 1 and $file = $_; } closedir DIR; return $file; } -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
