<html><head><style type="text/css"><!-- DIV {margin:0px;} --></style></head><body><div style="font-family:times new roman,new york,times,serif;font-size:12pt">Shoot, I forgot about adding a handler (a little too used to mod_perl I guess).<br><br>Thank you Lara for the great detail for this OS.<br><br>-Darin<br><div>&nbsp;</div>Not a shred of evidence exists in favor of the idea that life is serious.<br>- Brendan Gill<div><br></div><div style="font-family: times new roman,new york,times,serif; font-size: 12pt;"><br><div style="font-family: arial,helvetica,sans-serif; font-size: 10pt;"><font face="Tahoma" size="2"><hr size="1"><b><span style="font-weight: bold;">From:</span></b> Lara Ortiz de Montellano &lt;lara.ortiz.de.montellano@comcast.net&gt;<br><b><span style="font-weight: bold;">To:</span></b> sanfrancisco-pm@pm.org<br><b><span style="font-weight: bold;">Sent:</span></b> Monday, November 17, 2008 2:21:27 PM<br><b><span style="font-weight:
 bold;">Subject:</span></b> Re: [sf-perl] perl on a mac<br></font><br>
1. Re: perl on a mac (Walt Sanders)<br><br>&gt; Terminal won't run it of course, it just spits that code back at me.&nbsp;  But, if I try to run it in a browser, of try to preview it in an&nbsp; editor, it still spits code back at me.&nbsp; This is any program that runs&nbsp; perfectly fine when I upload it to any one of my ISP servers.&nbsp; I can&nbsp; just download any working .cgi or .pl from one of my websites and it&nbsp; won't run on my machine.<br>&gt;&nbsp; <br><br>To expand a bit on Darin's instructions in a Mac specific context (and this is going to be long and possibly something you already know)...<br><br>It sounds like you're seeing the correct, but raw HTML when you expect to see interpreted HTML if you run the code on the command line, and raw perl code if you open it in the browser?<br><br>If so, the deal is that the terminal/command line executes the Perl but does not render HTML.&nbsp;  This is correct and expected behaviour.&nbsp; 
 You should see the same thing if you run the script on Windows under<br>&nbsp;  Start-&gt;<br>&nbsp; &nbsp; &nbsp;  Run-&gt;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  cmd [OK]<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  c:&gt; perl c:\some\path\to\your\script.pl<br><br>Opening the perl script directly in the browser will get you the raw Perl code because the browser itself cannot execute the Perl code, it only understands the HTML (and figures anything else is plain text).<br><br>So... you need to execute the Perl by having your browser ask a web server to execute the script and return the (HTML) contents to the browser.<br><br>To do this:<br><br>1) Configure your web server to allow CGI scripts:<br><br>a) In Terminal, use the whoami command to see what the Mac thinks your user id is.<br><br>b) Under /etc/httpd/users (under 10.4) or /etc/apache2/users/ (10.5) create a file called username.conf where "username" is your userid name on the mac.<br><br>c) In the
 /etc/apache2/users/username.conf file, add the text:<br><br>&lt;Directory "/Users/username/Sites/"&gt;<br>&nbsp;  AllowOverride All<br>&lt;/Directory&gt;<br><br>d) Create the file /Users/username/Sites/.htaccess<br><br>set the permissions on the file:<br><br>sudo chgrp www .htaccess<br>chmod 750 .htaccess<br><br>and in the file, add the text:<br><br>AddHandler cgi-script .pl<br>Options ExecCGI<br><br>e) Under the apple menu, choose System Preferences and click on Sharing, then turn off (by unticking) Personal Web Sharing, then turn it back on (by ticking Personal Web Sharing).<br><br>2) Set your script up to be accessible to the web server<br><br>a) In Terminal, run&nbsp; &nbsp;  which perl&nbsp; &nbsp;  to see which Perl you're using, and make a note of the path (usually /usr/bin/perl)<br><br>b) Add a shebang line to your perl script to tell the web server how to execute your script, using the path&nbsp; you got in 2a:<br><br>#!/usr/bin/perl<br><br>c)
 copy or move your file to /Users/username/Sties/scriptname.pl<br><br>d) Set the file permissions to allow world execute on the script:<br><br>chmod a+x /Users/username/Sites/scriptname.pl<br><br>3) View the file in your browser at<br><br><a href="http://localhost/%7Eusername/scriptname.pl" target="_blank">http://localhost/~username/scriptname.pl</a><br><br>Do you see what you were expecting? <br>If so, you'll want to read up a bit on Apache&nbsp; CGI&nbsp; and you may also want to tweak the Apache and script file permissions to make it a little more secure.<br><br>-Lara O.<br><br>_______________________________________________<br>SanFrancisco-pm mailing list<br><a ymailto="mailto:SanFrancisco-pm@pm.org" href="mailto:SanFrancisco-pm@pm.org">SanFrancisco-pm@pm.org</a><br><a href="http://mail.pm.org/mailman/listinfo/sanfrancisco-pm" target="_blank">http://mail.pm.org/mailman/listinfo/sanfrancisco-pm</a><br></div></div></div></body></html>