?
Solved

500 Internal Server Error

Posted on 2006-04-11
9
Medium Priority
?
325 Views
Last Modified: 2013-12-25
I am pretty new to CGI programming and am having a problem. When I run a cgi script like this it works okay:

#!/usr/local/bin/perl
print "Content-type: text/html\n\n";
print "<HTML><BODY BGCOLOR=white>\n";
print "<B>Local configuration:</B><BR><BR>\n";
$date = `date`;
print "Now is: $date<BR>";
$uname = `uname -sr`;
print "The operating system is: <B>$uname</B><BR>\n";
print "The web server is: " . $ENV{SERVER_SOFTWARE} . "<BR>\n";
$pwd = `pwd`;
print "The current directory is <B>$pwd</B><BR>\n";
$login = (getpwuid($<))[0];
print "<BR>The cgi scripts run as user <B>" . $login;
print "</B> (if your cgi needs to write to a file,<BR>";
print "make sure the user $login has permissions to write to the file).<BR>\n";
print "<BR><BR>\n</BODY>\n</HTML>\n";

However as soon as I put anything even just a space between the following two lines, I get an 500 Internal Server Error:

#!/usr/local/bin/perl
print "Content-type: text/html\n\n";

What am I doing wrong, is this a permissions issue?
0
Comment
Question by:AJKConcepts
  • 3
  • 3
  • 3
9 Comments
 
LVL 85

Expert Comment

by:ozo
ID: 16428194
How do you put the space between the two lines?
How did you create the script that works ok?
What are the permissions of the scripts?
0
 
LVL 2

Author Comment

by:AJKConcepts
ID: 16428338
First of all let me preface this by saying that this is not my site. I am a web developer but I work in a windows environment and am only proficient in things like ASP and SQLserver. One of our clients called us with this problem, they are hosting somewhere else on a unix machine. He has a cgi script called upload.cgi and he wants to know why it isn't working so I am trying to help him.

I didn't come up with the cgi script that works, it was already there. I was trying to figure out why that cgi file was working and the upload.cgi file is giving a 500 Internal Server Error.

To make the space I opened the cgi script in visual interdev so that I could mess with it and I just pressed the enter key to make a blank line between the two lines.

The permissions of the scripts are both owner - read write execute   group - read execute  all users - read execute
0
 
LVL 85

Expert Comment

by:ozo
ID: 16428508
If you are working in a windows environment you may have introduced windows end of line characters "\r" when you changed the file, which could have confused unix.
If you also accidentally made a blank line before the first #! that could have caused a problem too
0
How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

 
LVL 2

Author Comment

by:AJKConcepts
ID: 16429488
Is there any program or anything that I can modify the cgi file in on my windows computer that will not add any characters that will confuse Unix?
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 16429756
any reliable editor will allow you to write in any format (vi, textpad, ultraedit, notepad++, just to mention a few), then ensure that you upload the files in bin mode when using ftp.
0
 
LVL 2

Author Comment

by:AJKConcepts
ID: 16430398
Ok I opened the file in textpad and all I put into it is #!/usr/local/bin/perl and then tried it and I am still getting the 500 Internal Server Error.
0
 
LVL 85

Accepted Solution

by:
ozo earned 2000 total points
ID: 16430509
You will probably get a error if you don't have something like
print "Content-type: text/html\n\n";
in the file
Does the error message give any more information?
Are there any server error logs?
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 16430577
did you ensure that the file was saved in proper format, in particular that it does not conain returns (aka \r aka \015)?
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 16431393
hmm, how does ozo's comment help?
the posted script in the question contains this line ... just wondering ...
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

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

This tutorial will discuss the log-in process using WhizBase. In this article I assume you already know HTML. I will write the code using WhizBase Server Pages, so you need to know some basics in WBSP (you might look at some of my other articles abo…
I hope you'll find this tutorial useful and interesting. So let's try to extend Tcl with a new package.  For anyone more deeply interested please check out the book "Practical Programming in Tcl and Tk". It's really one of the best written books abo…
Learn the basics of lists in Python. Lists, as their name suggests, are a means for ordering and storing values. : Lists are declared using brackets; for example: t = [1, 2, 3]: Lists may contain a mix of data types; for example: t = ['string', 1, T…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Suggested Courses
Course of the Month14 days, 1 hour left to enroll

807 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