or Connect
AppleInsider › Forums › General › Genius Bar › CGI-Executables and running CGI on OSX
New Posts  All Forums:Forum Nav:

CGI-Executables and running CGI on OSX

post #1 of 11
Thread Starter 
Alright everyone, this issue has plagued me since day one of OS X. I wan ttorun CGI scripts on my OS X box and I cannot get it to work. Everytime I try to run CGI I get:

[quote]Internal Server Error

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

Please contact the server administrator, [no address given] 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.

Apache/1.3.22 Server at XXXXXX Port 80<hr></blockquote>

Anoyone else have this problem or know how to fix it? It serves web pages properly otherwise. Just no CGI.
NoahJ
"It is unwise to be too sure of one's own wisdom. It is healthy to be reminded that the strongest might weaken and the wisest might err." - Mahatma Gandhi
Reply
NoahJ
"It is unwise to be too sure of one's own wisdom. It is healthy to be reminded that the strongest might weaken and the wisest might err." - Mahatma Gandhi
Reply
post #2 of 11
Make sure you set the directory you're running the CGI in to have execute permissions. You should have a "cgi-bin" directory to do this.
Be quiet, Brain, or I'll stab you with a Q-tip
Reply
Be quiet, Brain, or I'll stab you with a Q-tip
Reply
post #3 of 11
In case my post wasn't clear enough:

You want to change the permissions on the directory where you're running the CGI scripts to allow the owner full control, the group read and execute and others read and execute. Do this by running this command in the terminal

chmod 755 yourdirectory

and then do the same thing to the cgi files.

If that doesn't work, you might want to check your source code. If the code is referencing a part of your system that isn't installed or installed in a different location you'll get the same 500 server message.

Example:

Sendmail could be installed in:

/usr/sbin/sendmail
/usr/lib/sendmail
/usr/bin/sendmail

So make sure your code is referencing it from the right place.
Be quiet, Brain, or I'll stab you with a Q-tip
Reply
Be quiet, Brain, or I'll stab you with a Q-tip
Reply
post #4 of 11
By default, Apache will look for cgi's in /Library/WebServer/CGI-Executables/ and will only run cgi's located in that directory. The problem you're having could be because of the permissions or because you're trying to run cgi's from a directory outside that one. You either have to edit the httpd.conf file to allow scripts to be run from other directories (not recommended) or move your files there.

BTW, cgi-bin is just an alias for the CGI-Executables directory. Don't manually create that directory.

Ex: if you have a script called test.cgi in you /Library/WebServer/CGI-Executables directory, you would call it with: <a href="http://yourservername/cgi-bin/test.cgi" target="_blank">http://yourservername/cgi-bin/test.cgi</a> HTH.
post #5 of 11
Thread Starter 
Ok, the test.cgi worked, but the other CGI's I have do not. The major difference seems to be that the test.cgi is just a CGI script where the others are perl based. Any suggestions there? BTW the CGI folder seems to be 775 and the scripts are at least 755 if not 775.
NoahJ
"It is unwise to be too sure of one's own wisdom. It is healthy to be reminded that the strongest might weaken and the wisest might err." - Mahatma Gandhi
Reply
NoahJ
"It is unwise to be too sure of one's own wisdom. It is healthy to be reminded that the strongest might weaken and the wisest might err." - Mahatma Gandhi
Reply
post #6 of 11
Are you using the shebang line properly, with the correct path? #!/usr/bin/perl? Maybe you could post the script here so we can look at it? I'm trying to rack my brain to remember what I had to do to get it working right. It's been a long time since I've used cgi's (PHP is much better suited to my needs).
post #7 of 11
I just remembered! Mac line endings != Unix line endings. That's what drove me up the wall for, oh, 3 months. Maybe that's it? (To see, open up the terminal and look at the file in pico. If it's all on one line and garbled that's your problem.

Here's a little perl tidbit that will fix the problem, if that's what it is:

perl -pi -e 's/\
/\
/g' &lt;filename&gt;. HTH.
post #8 of 11
It's been awhile since I wrote a CGI as well... Are you printing out the CGI header properly? IIRC every CGI must print out two lines before outputting HTML:
[code]
Content-type: text/html

</pre><hr></blockquote>
The second line is an empty line (just a "\
").
"There are two ways of constructing a software design: one way is to make it so simple that there are obviously no deficiencies, and the other way is to make it so complicated that there are no...
Reply
"There are two ways of constructing a software design: one way is to make it so simple that there are obviously no deficiencies, and the other way is to make it so complicated that there are no...
Reply
post #9 of 11
Thread Starter 
[quote]Originally posted by torifile:
<strong>I just remembered! Mac line endings != Unix line endings. That's what drove me up the wall for, oh, 3 months. Maybe that's it? (To see, open up the terminal and look at the file in pico. If it's all on one line and garbled that's your problem.

Here's a little perl tidbit that will fix the problem, if that's what it is:

perl -pi -e 's/\
/\
/g' &lt;filename&gt;. HTH.</strong><hr></blockquote>

This actually fixed about 90% of the problem. Thanks. Now I am getting other errors. Maybe perl is messed up? the error is:


Software error:

Can't locate DBI.pm in @INC (@INC contains: ./ ./Sources ./install_modules /System/Library/Perl/darwin /System/Library/Perl /Library/Perl/darwin /Library/Perl /Network/Library/Perl/darwin /Network/Library/Perl .) at (eval 7) line 3.

For help, please send mail to the webmaster ([no address given]), giving this error message and the time and date of the error. Expires: Mon, 26 Jul 1997 05:00:00 GMT Date: Thu, 07 Mar 2002 09:19:16 GMT Content-Type: text/html
NoahJ
"It is unwise to be too sure of one's own wisdom. It is healthy to be reminded that the strongest might weaken and the wisest might err." - Mahatma Gandhi
Reply
NoahJ
"It is unwise to be too sure of one's own wisdom. It is healthy to be reminded that the strongest might weaken and the wisest might err." - Mahatma Gandhi
Reply
post #10 of 11
DBI.pm I think is the perl connection to mysql, right? You've got to install that manually. Are you trying to connect to a database using perl?
post #11 of 11
Thread Starter 
[quote]Originally posted by torifile:
<strong>DBI.pm I think is the perl connection to mysql, right? You've got to install that manually. Are you trying to connect to a database using perl?</strong><hr></blockquote>

Sorry, i should have told you what I was doing right off. i am trying to get <a href="http://www.ikonboard.com" target="_blank">Ikonboard</a> working under OS X for personal reasons. And the funny part is, without even knowing what I am doing you have been able to get more working for me than they have being the writers of the software. <img src="graemlins/bugeye.gif" border="0" alt="[Skeptical]" /> Although i chose to not do the mySQL DB as I just wanted to use their default database for posts. I do not expect to need the industiral strength of mySQl right now.
NoahJ
"It is unwise to be too sure of one's own wisdom. It is healthy to be reminded that the strongest might weaken and the wisest might err." - Mahatma Gandhi
Reply
NoahJ
"It is unwise to be too sure of one's own wisdom. It is healthy to be reminded that the strongest might weaken and the wisest might err." - Mahatma Gandhi
Reply
New Posts  All Forums:Forum Nav:
  Return Home
  Back to Forum: Genius Bar
AppleInsider › Forums › General › Genius Bar › CGI-Executables and running CGI on OSX