+ Reply to Thread
Results 1 to 6 of 6

Thread: How to set up cgi

  1. #1
    unobtainium's Avatar
    unobtainium is offline x10Hosting Member unobtainium is an unknown quantity at this point
    Join Date
    Mar 2010
    Posts
    5

    How to set up cgi

    The calling page containing the form submitting the request to a python script in cgi-bin works on my personal server. It fails when I load it up on x10hosting. Obviously, it is not set up properly. How to do that?

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

    Re: How to set up cgi

    This topic has been covered before. Search for the relevant threads. If you're still having problems, post your specific problem, including what you've done, a link to a live page, what you expect to happen and what actually happens, including any error messages. We're not psychic.
    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.

  3. #3
    unobtainium's Avatar
    unobtainium is offline x10Hosting Member unobtainium is an unknown quantity at this point
    Join Date
    Mar 2010
    Posts
    5

    Re: How to set up cgi

    I did search and came up with nothing.
    Please suggest how to reach one of those threads.

  4. #4
    dlukin is offline x10 Lieutenant dlukin is on a distinguished road
    Join Date
    Oct 2009
    Posts
    427

    Re: How to set up cgi

    So much for the helpful members of this forum.

    1. Make sure the script has permissions set to 0755
    2. Script should have rough outline like:

    Code:
    #!/usr/bin/env python
    import os
    import sys
    
    print("Content-type: text/html")
    print("")
    
    print("<html>")
    print("<body>")
    
    print( "GET / POST Information")
    print("<pre>")
    
    
    print "Request method: " , os.environ[ 'REQUEST_METHOD' ]
    print "Query string: " ,  os.environ[ 'QUERY_STRING' ]
    count = 0 
    for line in sys.stdin:
        count = count + 1
        print line
        if count > 100:
            break
    print ""
    print("</pre>")
    print("</body>")
    print("</html>")
    Make sure you print out the HTTP Content header before any output. Follow it by a blank line. They are running Python 2.6 I think. Definitely not 3.

    3. If the script is in cgi-bin , you should be set to go
    If it is anywhere else, make sure you have a line:

    Code:
    AddHandler cgi-script .py
    in your .htaccess file

    4. If your script still flubs, post any error messages back here and I can try to help.

  5. #5
    unobtainium's Avatar
    unobtainium is offline x10Hosting Member unobtainium is an unknown quantity at this point
    Join Date
    Mar 2010
    Posts
    5

    Re: How to set up cgi

    Thank you so much.
    I was totally unaware of how to set permissions.
    I just tried FileZilla and it worked.
    Now, cgi works just fine.
    Thank you.

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

    Re: How to set up cgi

    Quote Originally Posted by unobtainium View Post
    Please suggest how to reach one of those threads.
    The first link in my first post is to a search that lists those threads (hence the sig). The first result shows how to access input variables. The second (and other) results tell you about permissions. Both have sample scripts.
    Last edited by misson; 06-05-2010 at 12:15 AM.
    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.

+ Reply to 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