I have gotten a random image script and I am trying to adapt it for my needs, being new to perl. So, with respect to the posting guidelines, I am going to try to give enough details without filling this post with all of my script.
First, let me say that I have used this script with another host just the way I have it and it works just fine.
I have set the file permissions to 755. The path to Perl is #!/usr/local/bin/perl as the host has told me. My script ending is .pl
my @images = ({ file => '/Images/welcome/new/lily_bg.jpg',
alt => 'My Site Here' },
{ file => '/Images/welcome/new/mirror.jpg',
alt => 'My Site Here' };
This is how I have linked to my images.
And this is how I am calling the code in my HTML
<!--#include virtual="cgi-bin/random.pl" -->
Just to be safe I have named the file with the .shtml extension.
Nonetheless, every time I try to run the script I get this error message were my image should be, [an error occurred while processing this directive]
This script has worked for me on every other website I have used it on except this one. I have asked my host to check it out and they say it is my problem and I am out of luck.
Can anyone give me a hint as to what is going on here. If you need more info I would be happy to provide it.
Thank you in advance,
Cienwen
<!--#include virtual="http://www.yoursite.com/cgi-bin/random.pl" -->
the perl code you posted is not valid syntax but maybe that's just a copy/paste error, it's missing the right parenthesis ')' at the end of the array assignment:
my @images = (
{file => '/Images/welcome/new/lily_bg.jpg',
alt => 'My Site Here' },
{file => '/Images/welcome/new/mirror.jpg',
alt => 'My Site Here' }
); #<-- this is missing in your code;
This is the error log. Maybe someone can make sense of it.
[Tue May 30 18:06:32 2006] [error] [client ######] unable to include "cgi-bin/random.pl" in parsed file /home/username/public_html/welcome02.shtml
[Tue May 30 18:06:32 2006] [error] [client ######] Premature end of script headers: /home/username/public_html/cgi-bin/random.pl fopen: Permission denied failed to open log file
[Tue May 30 18:02:57 2006] [error] [client ######] unable to include "cgi-bin/random.pl" in parsed file /home/username/public_html/welcome02.shtml
[Tue May 30 18:02:57 2006] [error] [client ######] Premature end of script headers: /home/username/public_html/cgi-bin/random.pl fopen: Permission denied failed to open log file
(1) The script file was not uploaded in ASCII format. Be sure to use Notepad or other simple text file editor to edit your Perl scripts and be sure your FTP program is set to upload in ASCII format. Do not use WordPad or other word processors on Perl scripts.
(2) There is a syntax error in the script itself. Simple explaination, but often the most frustrating and difficult to correct. Start with the possible error a previous poster mentioned here.
(3) If running on an Apache-based server, the script must begin any output with a proper header that includes the MIME-type, as in "Content-type: text/html\n\n".
(4) If running in a Unix/Linux/*nix environment, the permissions setting for either the script file itself or the folder where it resides does not have "Execute" permission. Make sure the permission setting on the script file is 755 with the CHGMOD command. Many FTP programs have this function built-in. I know you mentioned this already, but check it again. Some hosts reset the permissions setting every time you upload a new version of a script.