Installing Perl on Ubuntu

Discussion in 'PHP' started by grutland, Nov 5, 2009.

  1. #1
    I hope this is the right section for this, but I've been looking into using Perl to create a few sites (bascially just to broaden my knowledge) and having some issues with running the scripts.

    If I execute the script through the terminal window (PuTTY) it returns fine, however if I run it through a browser I get a 500 error.

    I've got through so many different tutorials but none have helped me.
    I've been making sure I chmod the files to the correct setting.
    Made sure I have the right settings in my Apache config and installed the mod_perl module.
    Nothing seems to work though...

    The errors I'm getting in my error log are:

    [Thu Nov 05 18:54:54 2009] [error] [client 86.16.187.70] (2)No such file or directory: exec of '/dir/to/file/test.cgi' failed
    [Thu Nov 05 18:54:54 2009] [error] [client 86.16.187.70] Premature end of script headers: test.cgi
    Code (markup):
    Any one got any ideas what is going on?
     
    grutland, Nov 5, 2009 IP
  2. rainborick

    rainborick Well-Known Member

    Messages:
    424
    Likes Received:
    33
    Best Answers:
    0
    Trophy Points:
    120
    #2
    The error message indicates a "file not found" error. When you run a cgi script from a website, the root path may be different than when you use SSH via PuTTY. Check that first.

    Second, scripts run via CGI need to output proper MIME-type headers before any other output or you'll get an error. That is, you should have something like:
    
    print "Content-type: text/html\n\n";
    
    Code (markup):
    near the start of your code.
     
    rainborick, Nov 5, 2009 IP
    organicCyborg likes this.
  3. grutland

    grutland Active Member

    Messages:
    86
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    71
    #3
    I'm not sure how the root path can be different between the two...?
    I tried printing out the content-type line but didn't help at all.
     
    grutland, Nov 6, 2009 IP
  4. grutland

    grutland Active Member

    Messages:
    86
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    71
    #4
    What happens if I have saved the file in something other than UNIX format?
    I just read a couple more articles and realised my editor probably automatically saved it in DOS format.
     
    grutland, Nov 6, 2009 IP
  5. organicCyborg

    organicCyborg Peon

    Messages:
    330
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Also, if you're uploading it via ftp, make sure you've got the upload type set to ASCII. It's kind of the same thing as the DOS setting in the text editor.
     
    organicCyborg, Nov 6, 2009 IP
  6. grutland

    grutland Active Member

    Messages:
    86
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    71
    #6
    FTP isn't an issue, I'm saving directly to the server using Samba.
    So does that mean the DOS thing is quite a likely cause?
     
    grutland, Nov 6, 2009 IP
  7. grutland

    grutland Active Member

    Messages:
    86
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    71
    #7
    Thanks for the help, that was the problem.
    As soon as I saved it in UNIX and re-CHMOD-ed it, it worked fine.
     
    grutland, Nov 6, 2009 IP
  8. szalinski

    szalinski Peon

    Messages:
    341
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #8
    Damn, so that's why I was having the same
    problem!
    Some files worked and others gave this error, I couldn't figure out why since they were very similar. Thanks! :)
     
    szalinski, Nov 8, 2009 IP