+ Reply to Thread
Results 1 to 5 of 5
Like Tree2Likes
  • 2 Post By gpstrack

Thread: Python - shebang line not working

  1. #1
    gpstrack is offline x10Hosting Member gpstrack is an unknown quantity at this point
    Join Date
    Nov 2009
    Posts
    10

    Python - shebang line not working

    I have tried both shebang lines separately:

    #!/usr/bin/python
    #!/usr/bin/env python

    with the following script:

    print "Content-type: text/plain\n\n"

    def hi():
    print "hello"

    hi()


    Both times I get a 500 error. When I setup a cron to email me the output, I get an error saying:
    /usr/bin/python : Bad file name or directory

    My subdomain is on .elementfx.com, if that makes a difference?
    dinomirt96 and karimirt47 like this.

  2. #2
    descalzo's Avatar
    descalzo is offline Grim Squeaker descalzo has a brilliant futuredescalzo has a brilliant futuredescalzo has a brilliant future
    Join Date
    Jul 2009
    Location
    Ankh-Morpork
    Posts
    7,636

    Re: Python - shebang line not working

    On Chopin, the path to python shows as

    /usr/local/bin/python

    edit: 'which' also shows /usr/bin/python

    If you are going to run the script from the web, you have to add

    AddHandler cgi-script .py

    to the .htaccess file.

    And, of course, permissions set for execution, 0755

    Lastly, some people report problems getting cron jobs to work (usually php or wget).
    Last edited by descalzo; 11-14-2009 at 05:30 PM.

  3. #3
    gpstrack is offline x10Hosting Member gpstrack is an unknown quantity at this point
    Join Date
    Nov 2009
    Posts
    10

    Re: Python - shebang line not working

    Thanks descalzo

    I have the Addhandler thing done, and the script is in cgi-bin.
    0755, also done. and 0777. still no good.

    Anybody else have any thoughts? I will try again tomorrow, just incase the python server is down or whatnot.

  4. #4
    misson is offline x10 Spammer misson is a jewel in the rough
    Join Date
    Mar 2008
    Location
    Libertatia
    Posts
    2,506

    Re: Python - shebang line not working

    Both the shebang lines work for me with the sample script (aside: you can use the [code], [html] and [php] tags to delimit & format code samples). The error makes me suspect an issue with the character encoding or line-end discipline. Make sure you save the file as ASCII, not UTF-8, or at least make sure there's no BOM. If you're using FTP to upload the script, make sure you're using ASCII mode so the script uses Unix, rather than DOS, line termination (CR rather than CRLF). DOS line termination should cause an error like the one you're getting.
    Last edited by misson; 11-14-2009 at 10:11 PM.
    Be sure to read all pages linked in this post; they have further information that should prove useful. When asking for help, make sure you follow Eric Raymond's and Jon Skeet's guidelines for prompt, accurate responses. Please answer any questions I ask; they're not rhetorical (probably). Any posted code is intended as illustrative example, rather than a solution to your problem to be copied without alteration. Study it to learn how to write your own solution.
    Misson, not Mission.

  5. #5
    gpstrack is offline x10Hosting Member gpstrack is an unknown quantity at this point
    Join Date
    Nov 2009
    Posts
    10

    Re: Python - shebang line not working

    that solved it.

    i uploaded the file with command line FTP and set the mode to ASCII.

    cheers misson!

+ Reply to Thread

Similar Threads

  1. crontab not working
    By orgutz in forum Free Hosting
    Replies: 9
    Last Post: 09-11-2009, 07:41 PM
  2. I know.. Python Help again, but its not working..
    By nate_bro in forum Programming Help
    Replies: 15
    Last Post: 09-01-2009, 05:16 PM
  3. It works! ...
    By bpakidz in forum Programming Help
    Replies: 4
    Last Post: 09-07-2008, 11:12 PM
  4. November Desktop
    By n4tec in forum Off Topic
    Replies: 12
    Last Post: 11-08-2005, 07:18 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers