Follow us on...
Follow us on Twitter Follow us on Facebook
Register
Page 1 of 2 12 LastLast
Results 1 to 8 of 9

Thread: PErl on MAcOSX

  1. #1
    CSUMPI is offline Registered User
    Join Date
    Jul 2005
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    PErl on MAcOSX

    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

  2. #2
    CSUMPI is offline Registered User
    Join Date
    Jul 2005
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    PErl on MAcOSX

    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

  3. #3
    fryke's Avatar
    fryke is offline Super Moderator
    Join Date
    Sep 2000
    Location
    macosx.com
    Posts
    14,287
    Thanks
    15
    Thanked 120 Times in 109 Posts
    I see a permissions problem. Do a "chmod 755 perltext.cgi" while you're in that directory...?
    Mac user since 1987. Running Mac OS X 10.8 Mountain Lion on a MacBook Air 11" & an iMac 27" and whatever's newest for my iPhone 4s, iPad 3 and AppleTV 2.
    Apple Certified System Administrator 10.6, Apple Sales Professional 2008-2011, Apple Certified Mac Technician.

  4. #4
    ElDiabloConCaca's Avatar
    ElDiabloConCaca is offline U.S.D.A. Prime
    Join Date
    Aug 2001
    Location
    San Antonio, Texas
    Posts
    14,490
    Thanks
    10
    Thanked 648 Times in 610 Posts
    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>";
    print "</HEAD>";
    print "<BODY><H2>I just wrote a web page using Perl!</H2>";
    print "</BODY></HTML>";
    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.
    2009 Mac mini 2.0GHz • 2010 MacBook Air 11" • 2010 MacBook Pro 13" • LED 24" Cinema Display
    PowerMac G4 MDD dual 1.25GHz • PowerMac G4 Yikes! • iPad 2 32GB • 2 x iPhone 4 16GB • iPod Touch 8GB • iPod nano 1GB • iPod shuffle 1GB • AirPort Extreme dual-band • AppleTV
    http://www.jeffhoppe.com

  5. #5
    barhar is offline Registered User
    Join Date
    May 2005
    Posts
    1,339
    Thanks
    0
    Thanked 7 Times in 7 Posts
    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.
    )
    Last edited by barhar; August 11th, 2005 at 04:03 PM.

  6. #6
    ElDiabloConCaca's Avatar
    ElDiabloConCaca is offline U.S.D.A. Prime
    Join Date
    Aug 2001
    Location
    San Antonio, Texas
    Posts
    14,490
    Thanks
    10
    Thanked 648 Times in 610 Posts
    Quote Originally Posted by CSUMPI
    print ("Content-type:text/html\n\n");
    The linked articles do not include the parens around the print argument.
    2009 Mac mini 2.0GHz • 2010 MacBook Air 11" • 2010 MacBook Pro 13" • LED 24" Cinema Display
    PowerMac G4 MDD dual 1.25GHz • PowerMac G4 Yikes! • iPad 2 32GB • 2 x iPhone 4 16GB • iPod Touch 8GB • iPod nano 1GB • iPod shuffle 1GB • AirPort Extreme dual-band • AppleTV
    http://www.jeffhoppe.com

  7. #7
    kainjow is offline Registered User
    Join Date
    Nov 2000
    Posts
    949
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.

  8. #8
    yakasha is offline Registered User
    Join Date
    Jul 2005
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.

 

 
Page 1 of 2 12 LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •