[sf-perl] perl on a mac

Darin Fisher darin_fisher at yahoo.com
Sun Nov 16 10:33:59 PST 2008

This seems to be a web server configuration problem.
I am not very familiar with OS X stock configuration.

If you are running Apache v2.2.x add something similar to the following to the httpd.conf file:

<Directory "/usr/local/apache2/cgi-bin">
    AllowOverride None
    Options +ExecCGI
    Order allow,deny
    Allow from all

"/usr/local/apache2/cgi-bin" needs to be set to your specific cgi-bin directory.

Also, you will probably want this to be the last <Directory> clause in your configuration file.

The key option here is the 'Options +ExecCGI'.
See the Apache documentation for more information: http://httpd.apache.org/docs/2.2/mod/core.html#directory

Note, don't forget to restart Apache after making the changes.


 Not a shred of evidence exists in favor of the idea that life is serious.
- Brendan Gill

From: Walt Sanders <wsanders at pacificwebdesign.org>
To: Dan Lyke <danlyke at flutterby.com>
Cc: San Francisco Perl Mongers User Group <sanfrancisco-pm at pm.org>
Sent: Sunday, November 16, 2008 10:15:46 AM
Subject: Re: [sf-perl] perl on a mac

You quite right about the newbie bit, although I've written dozens of perl programs and have many websites using them, it has always been "get the job done" and 'someday' I'll master the sophistication.  This always worked on my PCs, but this Mac thing has me stopped cold.

Here is the top bit of output from Terminal:

Rang:desktop Rang$ perl idpass.cgi
Content-Type: text/html; charset=ISO-8859-1

<!DOCTYPE html
    PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US" xml:lang="en-US">
<title>ID Yourself</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<body bgcolor='#00ffff' onLoad='document.regform.name.focus();'><p><br><br><table width='650' cellspacing='0' cellpadding='0' border='0' align='center'><tr><td><center><a href='indexcm.html'><font size='2' color='#ff0000'><b>Return</b></font></a></center><p /><center><font size='4'><b>Member's Personal Site Registration</b></font></center><p /><center><font size='2' color='#ff0000'><b>(&nbsp;Please read and follow these instructions carefully!&nbsp;)</b></font></center><p />


The html is mostly done with print commands or with >> sections.  Here is the toping:

use strict;
use CGI qw( :standard );
use Fcntl qw( :flock );

print( header() );
print( start_html( 'ID Yourself' ) );

print("<body bgcolor='#00ffff' onLoad='document.regform.name.focus();'>");


All rather simple minded, but it works fine everywhere if I don't try it on my Mac!  If I run something without html, like

     #!/usr/bin/perl -w
     print "Content-type: text/html\n\n";
     print "Hello, world";

it works just fine.  I get just the two lines printed.


On Sunday, at , Dan Lyke wrote:

> On Sun, 16 Nov 2008 07:22:21 -0800
> Walt Sanders <wsanders at pacificwebdesign.org> wrote:
>> Terminal won't run it of course, it just spits that code back at
>> me. But, if I try to run it in a browser, of try to preview it in an
>> editor, it still spits code back at me.  This is any program that
>> runs perfectly fine when I upload it to any one of my ISP servers.
> Right. You need to either:
> 1. Pipe the output to an html file (although you'll need to strip the
> "Content-Type: text/html\n\n" first two lines). For instance:
>   stuff.cgi > output.html
>   perl -npi.bak -e 's/^Content-Type: .*$//;' output.html
>   And then open output.html in your web browser. If this is a Mac, you
>   could do "open output.html", on a Gnome based Linux machine, you'd
>   do "gnome-open output.html". Or, in either machine (or even Windows),
>   you can have that folder opened and double-click on output.html.
> 2. Run this under a web server on your local machine.
>> I can just download any working .cgi or .pl from one of my
>> websites and it won't run on my machine.
> When you say "won't run", what's the *exact* (copied and pasted) output
> you get from one of these programs. Does it look like:
> danlyke at danhplaptop:~$ ./test.pl
> bash: ./test.pl: /usr/share/perl: bad interpreter: No such file or
> directory danlyke at danhplaptop:~$
> If so, then the Perl interpreter on your web server is in a different
> place than on your Mac. However, it's fairly clear that you're a
> relative newbie (no harm in that, just gotta be more specific), so
> phrases like "Doesn't work" and "won't run" don't help us to debug the
> problem for you.
> Dan

SanFrancisco-pm mailing list
SanFrancisco-pm at pm.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.pm.org/pipermail/sanfrancisco-pm/attachments/20081116/587facb0/attachment-0001.html>

More information about the SanFrancisco-pm mailing list