View Full Version : Newbie installing perl script
fizzyfozzy
03-14-2006, 09:24 PM
Hi,
This is only the second perl script I have ever installed - only installed god help me if I was trying to actually learn to program anything because I am having so much trouble just installing a prewritten script!
If anyone can point me in the right direction I will be extreamly grateful!
I am trying to install the hishop script available here: http://www.hibyte.co.uk/software/hbpages/hishop_over.html
I have followed the directions and have used WS_FTP95 LE to upload the files in ASCII mode to my cgi-bin folder. I then right clicked each file to change it's chmod value to that which was indicated in the readme file.
(I'm not sure if this is the best way to upload/chmod my files - please advise if there is a better method)
Step 3 is then to run the check.pl file. Everytime I run this I just get a 500 internal server error.
I don't know where I am going wrong. The route to perl, I beleive, is correct as it is matches the route referenced in my FormMail.pl which works correctly and is stored in the same place.
Please reply if you can help me out at all.
Many thanks,
Michelle
mlseim
03-14-2006, 11:06 PM
Michelle ...
Have you tried a real simple Perl script, like the old "Hello World" script?
You should get something simple like this to work. The main reason is
to test the first line (called the "shebang"). The first line is typically
just like the example, but your webhost may want something different.
Try this out and see if it works:
#!/usr/bin/perl
print "Content-type: text/html\n\n";
print "
<html><head>
<title>Hello, world!</title></head>
<body>
<h1>Hello, world!</h1>
</body></html>
";
fizzyfozzy
03-15-2006, 08:46 PM
Nope i get a server error from that script too - what does that mean!?
http://www.strumdrum.com/cgi-bin/helloworld.pl
What am I doing wrong? :-(
mlseim
03-15-2006, 09:37 PM
I just noticed that you said your Formmail is working
correctly. Make sure the shebang line in the test script
is the same: #!/usr/bin/perl? Make it whatever you
have in FormMail, since that works.
Did you load the Formmail script yourself?
And you did upload the test script in ASCII and CHMOD to 755?
I don't know if this makes any difference ... with WSFTP-LE,
under Options, in the Session Tab, "Use Passive Transfer Mode"
should be checked.
Can't think of anything else ...
.
asperiea
03-18-2006, 07:26 PM
Hello all,
Im having the exact same error message. I run my own server(Hmmm, wonder if should be doing that:) but I tried to configure my httpd conf file to execute cgi scripts, I think maybe that is my problem. I know this is a cgi forum but all the info I read about apache and cgi gets me nowhere. So Im hoping that some one here can shed some light on this.
In my error log file is says this
[Sat Mar 18 11:37:46 2006] [error] (8)Exec format error: exec of /Library/WebServer/asperiea/CGI-Executables/first.pl failed
[Sat Mar 18 11:37:46 2006] [error] [client 24.165.242.130] Premature end of script headers: /Library/WebServer/asperiea/CGI-Executables/first.pl
I dont know what that means.
So is this a apache configure problem?
Oh and when I run ./first.pl from the terminal, I get this error
./first.pl: line 2: print: command not found
./first.pl: line 3: print: command not found
Thanks,
ASPeriea
Calilo
03-18-2006, 10:10 PM
fizzyfozzy :
Hi, the problem can be, because your server dosent allow cgi files to be executed outside certain folder, try executing the script, in the very same folder your formmail.pl script is in, that might be the reason, hope it is.
asperiea:
Premature end of script headers, mean there were missing headers in order to execute correctly the script, in other words in this case, the script has to know who and how is going to see the results of the script, so you have to add this:
print "Content-type: text/html\n\n";
so the browser can read them,
you seem to be running them throu your mac, be sure to be setting the correct file permission, from the terminal type
sudo chmode 755 file.pl
That should do the trick, also, the file has to be in cgi-execcutables folder, if you want to be able to execute them in any other folder this can help you (Extracted from your apache documentation). http://127.0.0.1/manual/
Explicitly using Options to permit CGI execution
You could explicitly use the Options directive, inside your main server configuration file, to specify that CGI execution was permitted in a particular directory:
<Directory /usr/local/apache/htdocs/somedir>
Options +ExecCGI
</Directory>
The above directive tells Apache to permit the execution of CGI files. You will also need to tell the server what files are CGI files. The following AddHandler directive tells the server to treat all files with the cgi or pl extension as CGI programs:
AddHandler cgi-script cgi pl
asperiea
03-19-2006, 12:23 AM
Hi, Calilo thanks for the reply,
The perl file does have the "print "Content-type: text/html\n\n";" line. I Have also chmod 755 to the file but still the same error 500? I wonder, I'm using virtual servers and the perl file is in a directory I named CGI-Executables within the directory that my virtual server is pointing to. and have changed the scriptAlias to point to that directory. Have added the Addhandler also but always the same message
Any thoughts,
Thanks,
ASPeriea
Calilo
03-19-2006, 04:11 PM
Hi asperiea, it seems more like a script problem than a apache problem, can u run other scripts, try running the HelloWord script posted above by mlseim, if that one runs you probably have a syntax error or something similiar.
the errors you posted say, that the "print "Content-type: text/html\n\n";" is not present, or maybe it is not the first thing the cgi tries to output.
check that if not, try posting the source code.
you can find more info on this page about the 500 internal server error
http://www.thesitewizard.com/archive/servererror.shtml
Calilo
asperiea
03-19-2006, 07:38 PM
Thats the script that I tried to run, but still the 500 error.
What source code are you referring to, the perl file source code? I just copied and pasted what mlseim posted. Or are you referring to my httpd.conf file?
Do you know where can I get the formmail.pl file?
Also, I saw some comments about the method that the file was uploaded to the server. Since I'm using my iMac, I just drag and drop files into place, would that have anything to do with the problem?
Ill give that link you posted a look through and see what I can find out.
this is what I did,
TDL-Server:/Library/WebServer/asperiea/CGI-Executables root# perl -wc first.pl
first.pl syntax OK
TDL-Server:/Library/WebServer/asperiea/CGI-Executables root# perl -w first.pl
Content-type: text/html
Hello, World.TDL-Server:/Library/WebServer/asperiea/CGI-Executables root#
So the file is fine and it apparently works fine so it must be the way I have the httpd.conf file set up? Do you know where I can get a httpd.conf file, I would like to start fresh with a new one, I did back of the current one but it also is doing the same thing.
Thanks,
ASPeriea
fizzyfozzy
04-20-2006, 06:47 PM
Hi again,
I contacted my isp about this problem and this is the reply i got:
"I tried running the script on the server and the error generated was that the perl path was incorrect. I looked and it seemed right visually, however when I deleted the line and retyped it the script started working.
At this point it would seem that perhaps your FTP program may be uploading the file in a strange way."
I have been using WS_FTP95 LE to upload my files. What other FTP clients can you suggest I try that maybe won't corrupt my files!? Being more of a designer than programmer I usually use dreamweaver but I can't choose between ascii and binary uploading in dreamweaver can I?
Thanks
KevinADC
04-20-2006, 08:55 PM
make sure to upload the scripts in ASCII mode (not binary) and set the chmod to 755 . I use WS_FTP95 LE all the time and there is no problem with it.
KevinADC
04-20-2006, 09:01 PM
any CGI script (one run from a browser) should include:
use CGI::Carp qw/fatalsToBrowser/;
this will help debug those pesky 500 ISE problems. It will print a more verbose error to the browser, even if the http headers have not already been printed. The only two errors (I know of) it will not print to the browser are an incorrect shebang line or if the script was uploaded in binary mode. Those two errors occur before the perl script can be compiled so there is no chance of detecting them. After you get a script running comment out the above line of code or remove it from the script.
vBulletin® v3.8.2, Copyright ©2000-2010, Jelsoft Enterprises Ltd.