OT - Perl Script in Apache

Parv parv at pair.com
Mon May 7 20:26:08 UTC 2007


in message <19743.80650.qm at web34410.mail.mud.yahoo.com>,
wrote White Hat thusly...
>
> Running Apache on a FreeBSD-6.2 machine, I am attempting to set up
> a web page that changes a specific image on a daily basis. I found
> a Perl script that is supposed to do this, but it seems to fail.
> All that is displayed is a red [X]. If I run the script from the
> command line, it works, as it should. Well, at least it displays
> the correct file name.
...
> To display an image simply use this in your HTML:
> <img src="/usr/local/www/apache22/data/perl_script.pl">
       ^ ^ ^ ^ ^
       ^ ^ ^ ^ ^
Note that here, value for "src" attribute, the file location which
can be accessed through the web server is needed.  If the Perl
program spits that out, great.  The program posted puts out
additional junk as is.

When you look at the source of the generated page where you use img
tag, what do you actually see?

You may need to employ SSI ...

  http://httpd.apache.org/docs/2.2/howto/ssi.html


... as in ...

  <img src="<!--#exec cmd="/path/to/perl_script.pl-"-->">


Do not forget to mark perl_script.pl executable.


> #!/usr/local/bin/perl
> 
> # find out the day of the year
> my $day_of_year = (localtime(time()))[7];
> 
> # define the path where the images live "." is the
> current directory

Please either carefully reformat the program or post the original as
is.  As you had posted, this program will not even compile as the
comments are not properly wrapped.

...
> print "Location: $files[$image_to_use]\n\n";

Does the image appear if you change the print argument to just the
file name, as in ...

  print $files[$image_to_use];

(... for there is no need to generate a HTTP header (which could be
considered erroneous) for your usage for the header has been already
sent as part of the page presented containing the img tag)?


  - Parv

-- 


More information about the freebsd-questions mailing list