# PErl on MAcOSX



## CSUMPI (Aug 11, 2005)

folks
I am using MAC OSX and perl is embedded in it.
All i want to do is to create a webpage from a perl script

Here is my script
#!/usr/bin/perl -w
print ("Content-type:text/html\n\n");
print "<HTML><HEAD>";
print "<TITLE>CGI Test</TITLE>";
print "</HEAD>";
print "<BODY><H2>I just wrote a web page using Perl!</H2>";
print "</BODY></HTML>";

The html page can be seen at 
http://kiwi.atmos.colostate.edu/test/cgi-bin/"perltext.cgi"

Why is there a problem??
Thanks


----------



## CSUMPI (Aug 11, 2005)

folks
I am using MAC OSX and perl is embedded in it.
All i want to do is to create a webpage from a perl script

Here is my script
#!/usr/bin/perl -w
print ("Content-type:text/html\n\n");
print "<HTML><HEAD>";
print "<TITLE>CGI Test</TITLE>";
print "</HEAD>";
print "<BODY><H2>I just wrote a web page using Perl!</H2>";
print "</BODY></HTML>";

The html page can be seen at 
http://kiwi.atmos.colostate.edu/test/cgi-bin/"perltext.cgi"

Why is there a problem??
Thanks


----------



## fryke (Aug 11, 2005)

I see a permissions problem. Do a "chmod 755 perltext.cgi" while you're in that directory...?


----------



## ElDiabloConCaca (Aug 11, 2005)

Just a few guesses:


> #!/usr/bin/perl -w
> print ("Content-type:text/html\n\n");         <-- *why the parens?*
> print "<HTML><HEAD>";
> print "<TITLE>CGI Test</TITLE>";
> ...





> http://kiwi.atmos.colostate.edu/test/cgi-bin/*"perltext.cgi"*
> *What's with the quotes in the name?*



Oddly enough, it works just fine with the quotes... the first time I load the page in Safari, it displays the code of your script.  If I hit "reload," it sort-of works, but I think you've got some kinks in the code that need to be worked out.


----------



## barhar (Aug 11, 2005)

The code is correct.  The same code appears at pageresource. 

"Content-type: text/html\n\n" is explained on the above web page.
I do not see purpose of the double quotes either.

You should try fryke's suggestion.

--------

(Added 16.53.31 - EDST

OK, I went to the next web page. Windoze'rs have to save the created '.pl' or '.cgi' files by surrounding the filename with double quotes.  I never saved a Perl file that way on a Mac or UNIX machine.

Below how to save the file is how to 'chmod' the file, as per fryke.
)


----------



## ElDiabloConCaca (Aug 11, 2005)

CSUMPI said:
			
		

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


The linked articles do not include the parens around the print argument.


----------



## kainjow (Aug 11, 2005)

You need to give the script certain permissions. I think it's 755, but not sure. Your FTP client should be able to do this.


----------



## yakasha (Aug 11, 2005)

May also be an apache problem (Im assuming you're running apache).
Try to add the execution permission to it (chmod 755 will work).  If that doesnt work, you'll need to try adding a file into your cgi-bin directory called:  .htaccess   (be sure to put the period in front)
In that file will be a single line:

Options +ExecCGI

If _that_ doesnt work, you'll need access to your apache conf file.  You'll need to modify it in one of many ways.  Either by adding the ExecCGI option to the right place, creating a <Directory> section for your cgi directory, or adding an AllowOverride to the right place.  If you read it carefully, change as little as possible, save a backup first, read the apache docs when necessary, and restart apache when finished, you should be able to do it yourself.


----------



## Captain Code (Aug 11, 2005)

Merged duplicate threads


----------

