Anyone running Python scripts?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Maqueo
    Junior Member
    • Apr 2004
    • 9

    Anyone running Python scripts?

    Hi,

    I noticed that Python is installed on the servers, but I don't manage to run a test script like this one:

    #! /usr/bin/python
    print "Content-Type: text/plain\n\n"
    print "Hello, Python"

    I get a "500 Internal Server Error" message...

    Anyone running Python scripts here?

    Thnx,
    Maqueo
  • Maqueo
    Junior Member
    • Apr 2004
    • 9

    #2
    PS

    PS:

    The test file is saved as test.py and at http://www.mydomain.com/cgi-bin/test.py when I try to run it

    Comment

    • Frank Hagan
      Senior Member
      • Mar 2004
      • 724

      #3
      I'm running the Mailman script, which is a python script. It works fine, but it self-installs from Cpanel so I'm afraid I don't know anything about python itself.

      Comment

      • Buddha
        Senior Member
        • Mar 2004
        • 825

        #4
        Just some thoughts:
        • Was the file uploaded in ASCII?
        • File permission allowing execution?
        • That shebang (#!) is on the first lines and does starts on the first character?
        "Whatcha mean I shouldn't be rude to my clients?! If you want polite then there will be a substantial fee increase." - Buddha

        Comment

        • Maqueo
          Junior Member
          • Apr 2004
          • 9

          #5
          Hi,

          Yes, I'm running the mailing lists scripts as well, and I found the path to the Python bin in a post in this forum. It seems Python is usually installed w/ Apache, but most host don't even mention it.

          Yes, the file was in ASCII (written in Notepad), #! is at the top and rights were set to 755.

          Cheers,
          M.

          Comment

          • Buddha
            Senior Member
            • Mar 2004
            • 825

            #6
            Originally posted by Maqueo
            Hi,
            Yes, the file was in ASCII (written in Notepad)...
            Maybe I picked the wrong word. Anyway, that's not the same as uploading it as text and not binary.
            "Whatcha mean I shouldn't be rude to my clients?! If you want polite then there will be a substantial fee increase." - Buddha

            Comment

            • Maqueo
              Junior Member
              • Apr 2004
              • 9

              #7
              Originally posted by Buddha
              Maybe I picked the wrong word. Anyway, that's not the same as uploading it as text and not binary.
              I uploaded it the with the same FTP client I up my PHP scripts with, so that shouldn't be the problem right?

              I'll double checklater when I get home though, try some other stuff. Maybe upload a Perl script to the bin just to be sure.

              Comment

              • Buddha
                Senior Member
                • Mar 2004
                • 825

                #8
                Originally posted by Maqueo
                I uploaded it the with the same FTP client I up my PHP scripts with, so that shouldn't be the problem right?

                I'll double checklater when I get home though, try some other stuff. Maybe upload a Perl script to the bin just to be sure.
                Yep it might. If the FTP client doesn't know .py is text and not binary that's could be the problem. WS_FTP defualts to binary when it doesn't recognize a file extension.
                "Whatcha mean I shouldn't be rude to my clients?! If you want polite then there will be a substantial fee increase." - Buddha

                Comment

                • Maqueo
                  Junior Member
                  • Apr 2004
                  • 9

                  #9
                  Hello World

                  Hi Buddha,

                  I got it running!

                  Solution was to rename *.py to *. or *.pl One of those "DUH" moments

                  I guess Python is installed but the extensions are not configured. This should be fun, I've just started to look into Python, but so far I really really like it...

                  Anyways, thanks again!

                  Maqueo

                  PS: Reg that bill... send it to my nigerian address, please include your bank account number and all your personal info. You'll be handsomely rewarded hehehe

                  Comment

                  • Dan
                    Member
                    • Mar 2004
                    • 99

                    #10
                    PS: Reg that bill... send it to my nigerian address, please include your bank account number and all your personal info. You'll be handsomely rewarded hehehe
                    LMAO That was pretty damn funny Maqueo!

                    Comment

                    • Buddha
                      Senior Member
                      • Mar 2004
                      • 825

                      #11
                      Originally posted by Maqueo
                      Hi Buddha,

                      I got it running!

                      Solution was to rename *.py to *. or *.pl One of those "DUH" moments
                      Python files have a shebang (#!) that tells the server what to use to execute it just like Perl files. Perl files are processed as cgi-script and the first thing the server does is look at the shebang. There's should be no problem using the extension .pl but seems like that could be kind of confusing for you. Might I suggest, you try renaming them to .py in cPanel using the file manager? Bet they still work.

                      I guess Python is installed but the extensions are not configured. This should be fun, I've just started to look into Python, but so far I really really like it...
                      Cpanel uses Python so I would bet there's an "AddHandler cgi-script .py" somewhere.

                      Anyways, thanks again!

                      Maqueo
                      Your welcome.

                      PS: Reg that bill... send it to my nigerian address, please include your bank account number and all your personal info. You'll be handsomely rewarded hehehe
                      Yeah that's pretty funny.
                      "Whatcha mean I shouldn't be rude to my clients?! If you want polite then there will be a substantial fee increase." - Buddha

                      Comment

                      • Maqueo
                        Junior Member
                        • Apr 2004
                        • 9

                        #12
                        Thanks again to you guys

                        In case anyone's interested, here are some cool Python links:


                        Explore the power of Python in the 2024: see our free tutorials and obtain the "Dive into Python" book by Mark Pilgrim in PDF and Kindle version.

                        Comment

                        Working...