?
Solved

Perl Script: Server Error 500

Posted on 2003-03-04
17
Medium Priority
?
284 Views
Last Modified: 2010-03-04
I have problem with "pass.pl" perl script. This Perl script is to verify the username and password from a client browser.

1. If the user input an incorect username or password it  will direct the user to the page with reject massege.

2. If you a user input the correct username and password it will direct user to the secured page.

Currently the script "pass.pl" is locate in the /usr/www/cgi-bin directory.

Here is the error message when I tried to submit the form:
--->
Server error!
The server encountered an internal error and was unable to complete your request.

Error message:
   Premature end of script headers: pass.pl
   If you think this is a server error, please contact the webmaster
   Error 500
   rmc-lnxsrv
   Tue 04 Mar 2003 01:23:33 PM EST
   Apache/2.0.40 (Red Hat Linux)
-->

Is there anyone can help me with this I greatly appreciate your help.
0
Comment
Question by:linxcelent
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 4
  • 4
  • +2
17 Comments
 
LVL 1

Expert Comment

by:buyboy
ID: 8067496
Normally you get this error when it isn't uploaded in ASCII mode or when your script is corrupted (while editing). You can change the upload mode in your FTP program.
0
 
LVL 15

Expert Comment

by:periwinkle
ID: 8068324
500 is a generic Apache error code that means a CGI script has failed.  

Buyboy has good first things to check - make certain that the script was uploaded as ascii, and that you've set the permissions properly to 755 (see http://toto.com/tips-cgi1.html for a discussion on setting file permissions if you are not familiar with them).

You should also check the error_log for the web server, to see if more information is available - often, more information will be given there.
0
 
LVL 8

Expert Comment

by:heskyttberg
ID: 8068685
Hi!

Make sure you have this at the top of perl script:
print "Content-type: text/html\n\n";

Next thing to check is:
Don't have cgi-bin group or world writeable.
pass.pl isn't group or world writeable.

pass.pl is executable.

Confirm that pass.pl works, by running it in shell environment.

Make sure pass.pl has same group belonging as web server is running as.

Regards
/Hans - Erik Skyttberg
0
Supports up to 4K resolution!

The VS192 2-Port 4K DisplayPort Splitter is perfect for anyone who needs to send one source of DisplayPort high definition video to two or four DisplayPort displays. The VS192 can split and also expand DisplayPort audio/video signal on two or four DisplayPort monitors.

 

Author Comment

by:linxcelent
ID: 8069163
Thank you Buyboy, Periwinkle, and Heskyttberg for your help. I will work on it tomorrow, because my script is running under my Intranet Server at my work. I can't access it at the moment.

I am greatly appreciate your help!
0
 

Author Comment

by:linxcelent
ID: 8072124
I am still getting the same error message after I did the change you asked me to do. I re-upload again with ASCII option. Is there any command in Linux I can use to check to see if the file I upload is an ASCII type? What can I do next step. Please help!
0
 
LVL 15

Expert Comment

by:periwinkle
ID: 8072152
Did you check the error_log for the server??  Generally, there will be more information there.

Do you have access to a Linux shell?  If so, try to run pass.pl from the command line and report back what happens!
0
 

Author Comment

by:linxcelent
ID: 8075020
This is the error message I get when I run #perl /var/www/cgi-bin/pass.pl

--->
Can't locate cgi-lib.pl in @INC (@INC contains: /usr/lib/perl5/5.8.0/i386-linux-
thread-multi /usr/lib/perl5/5.8.0 /usr/lib/perl5/site_perl/5.8.0/i386-linux-thre
ad-multi /usr/lib/perl5/site_perl/5.8.0 /usr/lib/perl5/site_perl /usr/lib/perl5/
vendor_perl/5.8.0/i386-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.0 /usr/
lib/perl5/vendor_perl .) at /var/www/cgi-bin/pass.pl line 3.
--->

#=================== Script starts ==================
#!/usr/bin/perl
require ("cgi-lib.pl");
&ReadParse(*form);
$user = $form{'user'};
$pass = $form{'pass'};

####################################################################
#Start here to edit the 5 variables that may need to be changed    #
####################################################################

# Edit Variable #1 of 5
#Set #!/usr/bin/perl at the top line 1 to point to your Perl interpretor
#Usually #!/usr/bin/perl or #!/usr/local/bin/perl

# Edit Variable #2 of 5
#Replace "california" on next line with your own username  
$myusername = "username";

# Edit Variable #3 of 5
#Replace "raisins" on next line with your own password
$mypassword = "123";

# Edit Variable #4 of 5
#Replace "granted.txt" on next line with your own file to be displayed when user/pass is correct
$protectedfile = "http://lnxsrv/~username";

# Edit Variable #5 of 5
#Replace "denied.txt" on next line with your own file to be displayed when user/pass is incorrect      
$accessdeniedfile = "http://lnxsrv/~username/error.html";

#That's it for this file Install Step #2. Now go to Install Step #3 on the readme.txt file.

####################################################################
#End of variable selection DO NOT edit below this line             #
####################################################################

if ($mypassword eq $pass && $myusername eq $user)
{
     print "Location: $protectedfile\n\n";
}
else
{
     print "Location: $accessdeniedfile\n\n";
}
#================== Script ends =====================

I do have the "cgi-lib.pl" within the /var/www/cgi-bin directory. What did I do wrong here? Help!
0
 
LVL 15

Expert Comment

by:periwinkle
ID: 8075080
try using a full path to cgi-lib.pl, like:

require "/home/yourhost/var/www/cgi-bin/cgi-lib.pl";
0
 

Author Comment

by:linxcelent
ID: 8082548
How can I check the error_log? Yes, I have access to a Linux shell.

I've been trying many ways:
changed the path within the "form" to "/var/www/cgi-bin/pass.pl"
===> Error 404
Object Not Found!

changed the path within the "form" to "/cgi-bin/pass.pl"
===> Error 500
Server Error!
The server encountered an internal error and was unable to complete your request.
Error message:
Premature end of script headers: pass.pl

--------------------------------------------------------
I checked the httpd.conf file to see if anything I can do to make cgi-script executable. This is what I found in the httpd.conf file:

ScriptAlias /cgi-bin/ "/var/www/cgi-bin/"
AddHandler cgi-script .cgi .pl

<Directory "/var/www/cgi-bin/">
    AllowOverride None
    options +ExecCGI
    Order Allow deny
    allow from all
</Directory>

Do you think I have problem with my httpd.conf file? What change do I have to make for cgi-script to be execute?

PS. I am greatly appreciate your help!


0
 
LVL 15

Expert Comment

by:periwinkle
ID: 8083263
are you on a shared server, or is it a server entirely for your own use?  If it is shared, the full path probably is something like:

/home/yourname/var/www/cgi-bin ...

You could run a utility script such as PerlDiver (free version located at:

http://www.scriptsolutions.com/programs/free/perldiver/     

This would tell you what your home environment was, and the full path to the scripts...

Look for the access_log and error_log for your server - probably in /var/log/httpd or /var/log or where your apache source is... then you can use a command like:

tail -100 error_log | more

to look at the last few entries...

0
 
LVL 8

Expert Comment

by:heskyttberg
ID: 8086573
Hi!

This error:
--->
Can't locate cgi-lib.pl in @INC (@INC contains: /usr/lib/perl5/5.8.0/i386-linux-
thread-multi /usr/lib/perl5/5.8.0 /usr/lib/perl5/site_perl/5.8.0/i386-linux-thre
ad-multi /usr/lib/perl5/site_perl/5.8.0 /usr/lib/perl5/site_perl /usr/lib/perl5/
vendor_perl/5.8.0/i386-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.0 /usr/
lib/perl5/vendor_perl .) at /var/www/cgi-bin/pass.pl line 3.
--->

Is because you don't have cgi-lib.pl in your cgi-bin dir.

Regards
/Hans - Erik Skyttberg
0
 
LVL 8

Expert Comment

by:heskyttberg
ID: 8086577
Hi!

So just put cgi-lib.pl in your cgi-bin dir and run the original pass.pl.

Regards
/Hans - Erik Skyttberg
0
 

Author Comment

by:linxcelent
ID: 8093506
Thank you heskyttberg for the reply.

I do have both "cgi-lib.pl" and "pass.pl" in my /var/www/cgi-bin/ directory. I am suspecting that something is doesn't work right within my httpd.conf configure file.

If you refer to my above comment above about my "ScriptAlias" path and the "Directory" path. Do you think this setting is right?

Any advice?
Thank you for your help, heskyttberg.
0
 
LVL 8

Accepted Solution

by:
heskyttberg earned 200 total points
ID: 8093625
Hi!

Well it dosen't look very good, you either do this which work on all apache I have installed:
ScriptAlias /cgi-bin/ "/var/www/cgi-bin/"
<Directory "/var/www/cgi-bin/">
   AllowOverride None
   Order Allow deny
   allow from all
</Directory>

Or you do this:
AddHandler cgi-script .cgi .pl
Alias /cgi-bin/ "/var/www/cgi-bin/"
<Directory "/var/www/cgi-bin/">
   AllowOverride None
   options +ExecCGI
   Order Allow deny
   allow from all
</Directory>

Regards
/Hans - Erik Skyttberg
0
 

Author Comment

by:linxcelent
ID: 8114132
Hi Erik,

I tried the configuration in your commend above, still no luck. I tried everything you told me and everything I posibly know still no luck :(

Here is my Linux Server functions. I have my Linux Server running as Samba Server sharing files with my internal Windows NT 4.0 domain, and as secondary DHCP server. Everything working quite well.

Now I want to have it running as an Intranet Apache Server. My httpd.conf file was configured to host my local web sites. It works find with "http://localhost/~username" but when I tried to run the "CGI" script It gives an error message "Server Error !". I read the menual about CGI script, they told me to make change to the httpd.conf configuration file, the same thing as you recommended me above. I tried that... Still no luck :(

Any other ways you think I can try? Thank you Soooo much for your help!

   
0
 

Expert Comment

by:webwarrior
ID: 8227532
Linxcelent,
Are you running apache on windows? If so, you may have to add this line in Sections 1: Global environment of your httpd.conf file.

ScriptInterpreterSource registry

So that your script will look something like this:

### Section 1: Global Environment
#
# The directives in this section affect the overall operation of Apache,
# such as the number of concurrent requests it can handle or where it
# can find its configuration files.
#

#
# ServerRoot: The top of the directory tree under which the server's
# configuration, error, and log files are kept.
#
# NOTE!  If you intend to place this on an NFS (or otherwise network)
# mounted filesystem then please read the LockFile documentation (available
# at <URL:http://httpd.apache.org/docs-2.0/mod/mpm_common.html#lockfile>);
# you will save yourself a lot of trouble.
#
# Do NOT add a slash at the end of the directory path.
#
ServerRoot "path/to/your/server"

ScriptInterpreterSource registry    <---- That is needed!!

#
# ScoreBoardFile: File used to store internal server process information.
# If unspecified (the default), the scoreboard will be stored in an
# anonymous shared memory segment, and will be unavailable to third-party
# applications.
# If specified, ensure that no two invocations of Apache share the same
# scoreboard file. The scoreboard file MUST BE STORED ON A LOCAL DISK.
#
ScoreBoardFile logs/apache_runtime_status
0
 

Expert Comment

by:webwarrior
ID: 8227550
OH! I forgot, your running Linux..

Make sure you uncomment this:

# To use CGI scripts outside of ScriptAliased directories:
# (You will also need to add "ExecCGI" to the "Options" directive.)
#
AddHandler cgi-script .cgi  <-- You can change that to .pl also.


Have you tried to run the file as a .cgi?
I find that sometimes when you get that error, you can change the extension to .cgi and chmod the file to 755 and run it that way..

Hope that helps.
0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

As Wikipedia explains 'robots.txt' as -- the robot exclusion standard, also known as the Robots Exclusion Protocol or robots.txt protocol, is a convention to prevent cooperating web spiders and other web robots from accessing all or part of a websit…
If you are a web developer, you would be aware of the <iframe> tag in HTML. The <iframe> stands for inline frame and is used to embed another document within the current HTML document. The embedded document could be even another website.
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses
Course of the Month7 days, 23 hours left to enroll

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question