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?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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?
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
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
Introduction to Web Design

Develop a strong foundation and understanding of web design by learning HTML, CSS, and additional tools to help you develop your own website.

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?
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.
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.
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?

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ahoffmannCommented:
did you ensure that the file was saved in proper format, in particular that it does not conain returns (aka \r aka \015)?
ahoffmannCommented:
hmm, how does ozo's comment help?
the posted script in the question contains this line ... just wondering ...
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Scripting Languages

From novice to tech pro — start learning today.