Jump to content
Sign in to follow this  
Singer

Troubles With Cgi-bin Script: Step 0

Recommended Posts

OK, this is my very, very, very first time trying to do something with CGI scripts. I tried using an existing Perl script which failed horribly, so I stepped way back and created the following very simple Perl script (of course, I may have a fundamental error in this, since I've never used Perl before :lol: ):

#!/usr/bin/perl

$abc = "1";

exit;

The script is in <domain name>/cgi-bin/test1.cgi and its permissions are set to 755.

 

At any rate, I'm getting the following error (the same as for the existing script) when I try to run it directly via the IE address bar:

Internal Server Error

 

The server encountered an internal error or misconfiguration and was unable to complete your request.

 

Please contact the server administrator, webmaster@<domain> 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.

 

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.

--------------------------------------------------------------------------------

Apache/1.3.27 Server at www.cantatasingers.ottawa.on.ca Port 80

The error log shows the following messages:

File does not exist: /home/<userid>/public_html/500.shtml

Premature end of script headers: /home/<userid>/public_html/cgi-bin/test1.cgi

I'm guessing the "File does not exist" msg is immaterial. Any thoughts about the rest?

 

Thanks!

Share this post


Link to post
Share on other sites

What is it you are trying to do? You have a definition but no operation.

Share this post


Link to post
Share on other sites

Good point! I've now modified it so it creates a simple web page:

#!/usr/bin/perl

 

print "<html>";

print "<head></head>";

print "<body>Hello world!!</body>";

print "</html>";

 

exit;

I expect to see
Hello world!!

Unfortunately, I'm still seeing the error message I mentioned in my previous post.

Share this post


Link to post
Share on other sites

Here's the script:

 

What you left out -- which is essential -- is the line:

print "Content-type: text/html;

(The "\n\n" are simply line feeds.

 

 

#!/usr/bin/perl

print "Content-type: text/html\n\n";

print "<html>";

print "<head></head>";

print "<body>Hello world!!</body>";

print "</html>";

 

exit;

Share this post


Link to post
Share on other sites

Hi, Phil,

 

Thanks for the input. While doing some reading a few days ago, I discovered that and gave it a try - no go. Today, I took the script as you had it and tried it - again, no go: same 500 error.

 

I'm not really sure what's happening here, and I don't have enough knowledge about CGI to make intelligent guesses.

Share this post


Link to post
Share on other sites

Sorry. But I'm much better at php than cgi. Otherwise I'd be able to help you out.

Share this post


Link to post
Share on other sites

Hmmm...thanks, Ty.

 

I tried it on your site and, I agree, it works quite well.

 

I've submitted a trouble ticket to the help desk, since I'm now wondering if there could be a configuration issue outside of my control (of course, I could still be totally wrong!). I referenced the ticket back to this topic and your script, so I would be happy if you would leave the script on your web site for a little while.

 

Thanks!

Share this post


Link to post
Share on other sites

I now have CGI scripts working! Now I can get on to the fun stuff.

 

I finally tracked down what I (as it turns out) was doing wrong: the CGI files were FTPing in binary, not text mode.

 

I have my domain FTP site set up in Windows Explorer and I tend to use that to transfer many of my files. I discovered today that Windows Explorer transfers .cgi files as binary, not text. That meant the Linux host was seeing CR-LF instead of straight LF for the end-of-line markers. And it turns out that's NOT a good thing.

 

I'm now using Core FTP Lite and HTML-Kit (a great freeware HTML, etc. editor, IMHO) to do the FTP transfers, since they do give me more feedback about the transfer and they transfer CGI files as text.

 

Thanks to those who supplied ideas and tried to help earlier on. I really appreciate it.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...