Hi All,
I'm new to the perl language....
I'm trying to understand how this language work and I hav develop the
following code:
in the webpage:
<form action="\cgi-bin\my_email.cgi" method="post">
<input type="submit" name="Submit" value="Submit" style="width:
93px" />
in the cgi-bin directori the "my_email.cgi" file:
#!/usr/bin/perl
print "Content-type: text/html\n\n";
print "Hello, world!\n";
I'm using this file just to test.... and the result is that is not
working....
when I click to the "submit" button, I get the following message:
Server error!
The server encountered an internal error and was unable to complete
your request.
Error message:
Premature end of script headers: my_email.cgi
If you think this is a server error, please contact the webmaster.
Error 500
Tue Jun 9 14:11:00 2009
Apache/2.0.55 (Ubuntu) mod_ldap_userdir/1.1.11 PHP/4.4.2-1.1
mod_vhost_ldap/1.0.0
what can I do?? do you know what can I cahe to find out the issue???
thanks
Vit
-----------------------------
Did you solve your problem?
1. Make sure you upload your Perl script to the correct folder on your web
server, which I think would be something like /cgi-bin. Otherwise you may
get a 404 error, saying it can't find the file.
2. Once on the server, ensure that you change the file's properties to
executable, otherwise, I think you'll get error 403, something about
refusing to display web page.
3. I get the 500 Internal Server Error when I have an error in my code. The
following script for example works fine:
#!/usr/bin/perl
$command= $];
$title = "Perl Version";
print "Content-type: text/html\n\n";
print "<html><head><title>$title</title></head><body>";
print "<h1>$title</h1>\n";
print "Perl version : ".$command;
print "<HR> \n";
system 'perl -v';
It displays the following -- yes I know it would be great if I had Perl 10
Perl Version
Perl version : 5.006001
-----------------------
This is perl, v5.6.1 built for i686-linux Copyright 1987-2001, Larry Wall
Perl may be copied only under the terms of either the Artistic License or
the GNU General Public License, which may be found in the Perl 5 source kit.
Complete documentation for Perl, including FAQ lists, should be found on
this system using `man perl' or `perldoc perl'. If you have access to the
Internet, point your browser athttp://
www.perl.com/, the Perl Home Page.
If however, I forget a semi colon like:
#!/usr/bin/perl
$command= $] # <--- Forgot Semicolon
$title = "Perl Version";
print "Content-type: text/html\n\n";
print "<html><head><title>$title</title></head><body>";
print "<h1>$title</h1>\n";
print "Perl version : ".$command;
print "<HR> \n";
system 'perl -v';
I get the following:
500 Internal Server Error
The server encountered an internal error or misconfiguration and was unable
to complete your request.
Please contact the server administrator, or webmaster and inform them of the
time the error occurred, and anything you might have done that may have
caused the error.
More information about this error may be available in the server error log.
4. You can also access your perl scripts directly instead of submitting a
form, for example, type the following in your address bar, and also use
/cgi-bin/my_email.cgi instead of \cgi-bin\my_email.cgi like Sinan said.
http://yourserver/cgi-bin/my_email.cgi
5. On a side note, I use the .pl extension instead of .cgi, but I may be a
minority? I think I even read that it was better to not use any extension
claiming that people don't have to know that the script is Perl or whatever?
6. Your print code looks ok, so perhaps the trouble is in your (pound bang)
line? Like you, mine is:
#!/usr/bin/perl
But perhaps you require it like this: (user) instead of (usr)???
#!/user/bin/perl
7. Are you sure your system supports Perl? If so, check if there are some
default Perl scripts in the /cgi-bin folder and check if they work, and if
they do, start with them.
Finally, I'm quite new to this group and Perl so I expect to be corrected
here!
PS. I recently learned that instead of uploading my scripts to test them, I
could install Strawberry Perl on my Windows XP and test my scripts locally.
I upload them to the server only once the bugs are out.
Cheers,
Guy D.