The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Problems with executing perl-scripts

Discussion in 'General Discussion' started by Freehen, Apr 17, 2004.

  1. Freehen

    Freehen Member

    Joined:
    Apr 10, 2004
    Messages:
    6
    Likes Received:
    0
    Trophy Points:
    1
    I have a problem executing Perl-scripts which I have uploaded via FTP.

    I always get a "500 Internal Server Error" while trying to run them.

    they are chmodded correctly and the sourcecode's fine.
    but it still doesn't let me execute them.

    What's wrong?
     
  2. PWSowner

    PWSowner Well-Known Member

    Joined:
    Nov 10, 2001
    Messages:
    2,948
    Likes Received:
    3
    Trophy Points:
    38
    Location:
    ON, Canada
    There are 2 things I do to debug scripts.

    1 - Add the following line to the script, anywhere after the first line and before the actual script functions:
    use CGI::Carp qw(fatalsToBrowser);
    This will make the browser tell you the error.

    2 - If your account includes shell access, in shell do the following, replacing username with your account username and scriptname with the scripts file name:
    perl -c /home/username/public_html/cgi-bin/scriptname.cgi
    This tests the script and tells you if there is a problem.
    You may need to adjust the line to the actual path to the script.
     
  3. Freehen

    Freehen Member

    Joined:
    Apr 10, 2004
    Messages:
    6
    Likes Received:
    0
    Trophy Points:
    1
    it does uses the "Fatalstobrowser" line and it has "print "Content-type: text/html\n\n";

    about shell, I do not have ability to use it.

    but there's no script problem cuz I got perl installed on my computer and there's no error there..

    however if I create the script using Cpanel's file manager.. the scripts works fine.. but not when uploading thru ftp..

    I must edit and create scripts online.. but I prefer using ftp as it will go a bit faster and I don't have to be signed in to the panel all the time when editting
     
  4. PWSowner

    PWSowner Well-Known Member

    Joined:
    Nov 10, 2001
    Messages:
    2,948
    Likes Received:
    3
    Trophy Points:
    38
    Location:
    ON, Canada
    That sounds like your ftp program is uploading the script in binary. Scripts have to be uploaded in ascii format.
     
  5. Freehen

    Freehen Member

    Joined:
    Apr 10, 2004
    Messages:
    6
    Likes Received:
    0
    Trophy Points:
    1
    LOL

    That was the problem :P

    On another server the Binary/ASCII didn't matter.. but here it did..

    Thanks squirrel
     
  6. PWSowner

    PWSowner Well-Known Member

    Joined:
    Nov 10, 2001
    Messages:
    2,948
    Likes Received:
    3
    Trophy Points:
    38
    Location:
    ON, Canada
    That would have been a windows server. That's one of the many differences between windows and unix/linux.
     
  7. Freehen

    Freehen Member

    Joined:
    Apr 10, 2004
    Messages:
    6
    Likes Received:
    0
    Trophy Points:
    1
    Actually the operative system was linux.
     
  8. PWSowner

    PWSowner Well-Known Member

    Joined:
    Nov 10, 2001
    Messages:
    2,948
    Likes Received:
    3
    Trophy Points:
    38
    Location:
    ON, Canada
    That's weird. I've been using cgi for 5 years now and always linux and always had to be ascii. Oh well. Probably another mystery never to be solved.
     
  9. Mandm84

    Mandm84 Registered

    Joined:
    Jun 11, 2004
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    1
    The man with the problem is actually trying to help me, with this being my problem, I uploaded it in ascii formatt. cuteftp automatically does that and .pl is addded to the auto ascii uploading list. SO that's not the problem.

     
  10. PWSowner

    PWSowner Well-Known Member

    Joined:
    Nov 10, 2001
    Messages:
    2,948
    Likes Received:
    3
    Trophy Points:
    38
    Location:
    ON, Canada
    Did you try these 2 things?

    Do your cpanel error logs show anything?
     
  11. Mandm84

    Mandm84 Registered

    Joined:
    Jun 11, 2004
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    1
    The perl script was already in my profile. But I haven't tryed the shell script, being I don't see it under the control panel, and don't think I have that option. But now what it is doing is trying to say that the perl script can't find a fiel in a directory that I know is there, I have actually looked and checked to make sure it's there, and it says it can't find it. I'm to the point of giving up. lol


     
  12. PWSowner

    PWSowner Well-Known Member

    Joined:
    Nov 10, 2001
    Messages:
    2,948
    Likes Received:
    3
    Trophy Points:
    38
    Location:
    ON, Canada
    Is the file in the same place the script thinks it's in?
    Is the file readable/writeable by the script? The file permissions would usually be 660 or 666.
     
  13. dave9000

    dave9000 Well-Known Member

    Joined:
    Apr 7, 2003
    Messages:
    891
    Likes Received:
    1
    Trophy Points:
    16
    Location:
    arkansas
    cPanel Access Level:
    Root Administrator
    If you can get shell access do a vi -b <scriptname> and see if you have ^m dos carriage returns at the EOL

    this will cause script errors on unix/linux

    there is a string substition in vi to change this to null but i right off hand don't remember it

    you can also use dos2unix converter to modify it
     
Loading...

Share This Page