500 Internal Server Error

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?
LVL 2
AJKConceptsAsked:
Who is Participating?
 
ozoCommented:
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
 
ozoCommented:
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
 
AJKConceptsAuthor Commented:
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
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

 
ozoCommented:
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
 
AJKConceptsAuthor Commented:
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
 
ahoffmannCommented:
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
 
AJKConceptsAuthor Commented:
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
 
ahoffmannCommented:
did you ensure that the file was saved in proper format, in particular that it does not conain returns (aka \r aka \015)?
0
 
ahoffmannCommented:
hmm, how does ozo's comment help?
the posted script in the question contains this line ... just wondering ...
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.