Weird cgi error

Discussion in 'Python' started by Jesse Aldridge, Feb 25, 2008.

  1. I uploaded the following script, called "test.py", to my webhost.
    It works find except when I input the string "python ". Note that's
    the word "python" followed by a space. If I submit that I get a 403
    error. It seems to work fine with any other string.
    What's going on here?

    Here's the script in action: http://crookedgames.com/cgi-bin/test.py

    Here's the code:

    #!/usr/bin/python
    print "Content-Type: text/html\n"
    print """
    <html>
    <body>
    <form action="test.py" method="post">
    <textarea name="data">
    </textarea>
    <INPUT type="submit" value="Submit">
    </form>
    </body>
    </html>
    """
    Jesse Aldridge, Feb 25, 2008
    #1
    1. Advertising

  2. Jesse Aldridge wrote:

    >I uploaded the following script, called "test.py", to my webhost.
    >It works find except when I input the string "python ". Note that's
    >the word "python" followed by a space. If I submit that I get a 403
    >error. It seems to work fine with any other string.
    >What's going on here?
    >
    >Here's the script in action: http://crookedgames.com/cgi-bin/test.py
    >
    >Here's the code:
    >
    >#!/usr/bin/python
    >print "Content-Type: text/html\n"
    >print """
    ><html>
    ><body>
    > <form action="test.py" method="post">
    > <textarea name="data">
    > </textarea>
    > <INPUT type="submit" value="Submit">
    > </form>
    ></body>
    ></html>
    >"""
    >
    >

    If you cant have access to the apache (?) error_log, you can put this in
    your code:
    import cgitb
    cgitb.enable()

    Which should trap what is being writed on the error stream and put it on
    the cgi output.

    Gerardo
    Gerardo Herzig, Feb 25, 2008
    #2
    1. Advertising


  3. > If you cant have access to the apache (?) error_log, you can put this in
    > your code:
    > import cgitb
    > cgitb.enable()
    >
    > Which should trap what is being writed on the error stream and put it on
    > the cgi output.
    >
    > Gerardo


    I added that. I get no errors. It still doesn't work. Well, I do
    get several errors about the missing favicon, but I'm pretty sure
    that's unrelated.
    Jesse Aldridge, Feb 25, 2008
    #3
  4. On Feb 25, 11:42 am, Jesse Aldridge <> wrote:
    > > If you cant have access to the apache (?) error_log, you can put this in
    > > your code:
    > > import cgitb
    > > cgitb.enable()

    >
    > > Which should trap what is being writed on the error stream and put it on
    > > the cgi output.

    >
    > > Gerardo

    >
    > I added that. I get no errors. It still doesn't work. Well, I do
    > get several errors about the missing favicon, but I'm pretty sure
    > that's unrelated.


    Oh, and yeah, the server's running Apache.
    Jesse Aldridge, Feb 25, 2008
    #4
  5. Jesse Aldridge

    Steve Holden Guest

    Jesse Aldridge wrote:
    > I uploaded the following script, called "test.py", to my webhost.
    > It works find except when I input the string "python ". Note that's
    > the word "python" followed by a space. If I submit that I get a 403
    > error. It seems to work fine with any other string.
    > What's going on here?
    >
    > Here's the script in action: http://crookedgames.com/cgi-bin/test.py
    >
    > Here's the code:
    >
    > #!/usr/bin/python
    > print "Content-Type: text/html\n"
    > print """
    > <html>
    > <body>
    > <form action="test.py" method="post">
    > <textarea name="data">
    > </textarea>
    > <INPUT type="submit" value="Submit">
    > </form>
    > </body>
    > </html>
    > """


    This is some kind of crooked game, right? Your code works fine on a
    local server, and there's no reason why it shouldn't work just fine on
    yours either. All you are changing is the standard input to the process.

    Since you claim to have spotted this specific error, perhaps you'd like
    to explain just exactly how you came across it. I mean that's a pretty
    specific input to test with ...

    Frankly I am not sure you are telling the truth about the code behind
    that page. If you *are* then you'd better provide specifics: Python
    version, Apache version, httpd.conf file, and so on. April 1 is still
    over a month away.

    regards
    Steve

    PS: consider closing the <textarea> tag on the same line as the opening
    tag to avoid spurious spaces in your pristine form.
    --
    Steve Holden +1 571 484 6266 +1 800 494 3119
    Holden Web LLC http://www.holdenweb.com/
    Steve Holden, Feb 25, 2008
    #5

  6. > This is some kind of crooked game, right? Your code works fine on a
    > local server, and there's no reason why it shouldn't work just fine on
    > yours either. All you are changing is the standard input to the process.
    >
    > Since you claim to have spotted this specific error, perhaps you'd like
    > to explain just exactly how you came across it. I mean that's a pretty
    > specific input to test with ...
    >
    > Frankly I am not sure you are telling the truth about the code behind
    > that page. If you *are* then you'd better provide specifics: Python
    > version, Apache version, httpd.conf file, and so on. April 1 is still
    > over a month away.
    >
    > regards
    > Steve
    >
    > PS: consider closing the <textarea> tag on the same line as the opening
    > tag to avoid spurious spaces in your pristine form.
    > --
    > Steve Holden +1 571 484 6266 +1 800 494 3119
    > Holden Web LLC http://www.holdenweb.com/


    Thanks for the reply.

    No, it's not a game, crookedgames.com is a mostly defunct games site
    that I was working on for a while. I'm just hosting the script
    there. What I am actually working on is a tool used to compare
    various things. Check it out here: http://crookedgames.com/cgi-bin/Language_Comparison.py
    Here's some input you can use to test with:

    Cats
    +2 Fuzzy
    -1 Medium Maintenance

    Fish
    +1 Low Maintenance
    -1 Stupid

    Dogs
    +2 Fuzzy
    -2 High Maintenance

    (note that there's supposed to be two spaces before the +/- symbols --
    in case my formatting doesn't go through)

    I originally created that tool because I wanted to compare programming
    languages, python among them, thus leading me discover this issue.

    Now, I'm very new to this web development stuff (this is my first real
    app), so it's quite likely that I'm just doing something stupid, but I
    can't figure out what.

    I'm using LunarPages. CPanel reports my Apache version as: 1.3.37
    (Unix)

    I added the line "print sys.version" to the test script, and that
    spits out: "2.3.4 (#1, Dec 11 2007, 05:27:57) [GCC 3.4.6 20060404 (Red
    Hat 3.4.6-9)]"

    I can't find any file called httpd.conf. It would be in /etc, right?
    I guess I don't have one.

    Still having the same problem.

    Here's the new contents of test.py:

    #!/usr/bin/python
    import cgitb, sys
    cgitb.enable()

    print "Content-Type: text/html\n"
    print sys.version
    print """
    <html>
    <body>
    <form action="test.py" method="post">
    <textarea name="data"> </textarea>
    <input type="submit" value="Submit">
    </form>
    </body>
    </html>
    """

    It's not a joke, honest :)
    Jesse Aldridge, Feb 25, 2008
    #6
  7. Jesse Aldridge

    Guest

    >
    >> This is some kind of crooked game, right? Your code works fine on a
    >> local server, and there's no reason why it shouldn't work just fine on
    >> yours either. All you are changing is the standard input to the process.
    >>
    >> Since you claim to have spotted this specific error, perhaps you'd like
    >> to explain just exactly how you came across it. I mean that's a pretty
    >> specific input to test with ...
    >>
    >> Frankly I am not sure you are telling the truth about the code behind
    >> that page. If you *are* then you'd better provide specifics: Python
    >> version, Apache version, httpd.conf file, and so on. April 1 is still
    >> over a month away.
    >>
    >> regards
    >> Steve
    >>
    >> PS: consider closing the <textarea> tag on the same line as the opening
    >> tag to avoid spurious spaces in your pristine form.
    >> --
    >> Steve Holden +1 571 484 6266 +1 800 494 3119
    >> Holden Web LLC http://www.holdenweb.com/

    >
    > Thanks for the reply.
    >
    > No, it's not a game, crookedgames.com is a mostly defunct games site
    > that I was working on for a while. I'm just hosting the script
    > there. What I am actually working on is a tool used to compare
    > various things. Check it out here:
    > http://crookedgames.com/cgi-bin/Language_Comparison.py
    > Here's some input you can use to test with:
    >
    > Cats
    > +2 Fuzzy
    > -1 Medium Maintenance
    >
    > Fish
    > +1 Low Maintenance
    > -1 Stupid
    >
    > Dogs
    > +2 Fuzzy
    > -2 High Maintenance
    >
    > (note that there's supposed to be two spaces before the +/- symbols --
    > in case my formatting doesn't go through)
    >
    > I originally created that tool because I wanted to compare programming
    > languages, python among them, thus leading me discover this issue.
    >
    > Now, I'm very new to this web development stuff (this is my first real
    > app), so it's quite likely that I'm just doing something stupid, but I
    > can't figure out what.
    >
    > I'm using LunarPages. CPanel reports my Apache version as: 1.3.37
    > (Unix)
    >
    > I added the line "print sys.version" to the test script, and that
    > spits out: "2.3.4 (#1, Dec 11 2007, 05:27:57) [GCC 3.4.6 20060404 (Red
    > Hat 3.4.6-9)]"
    >
    > I can't find any file called httpd.conf. It would be in /etc, right?
    > I guess I don't have one.
    >
    > Still having the same problem.
    >
    > Here's the new contents of test.py:
    >
    > #!/usr/bin/python
    > import cgitb, sys
    > cgitb.enable()
    >
    > print "Content-Type: text/html\n"
    > print sys.version
    > print """
    > <html>
    > <body>
    > <form action="test.py" method="post">
    > <textarea name="data"> </textarea>
    > <input type="submit" value="Submit">
    > </form>
    > </body>
    > </html>
    > """
    >
    > It's not a joke, honest :)
    > --

    It just doesnt make sense to me. I guess we all agree that is not a python
    problem, because that code does actually nothing but showing the form.
    , Feb 25, 2008
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. dorayme
    Replies:
    1
    Views:
    618
    richard
    Jan 21, 2011
  2. richard
    Replies:
    0
    Views:
    578
    richard
    Jan 21, 2011
  3. richard
    Replies:
    0
    Views:
    613
    richard
    Jan 21, 2011
  4. Beauregard T. Shagnasty

    Re: A Weird Appearance for a Weird Site

    Beauregard T. Shagnasty, Jan 21, 2011, in forum: HTML
    Replies:
    1
    Views:
    436
    Captain Paralytic
    Jan 21, 2011
  5. David Segall
    Replies:
    0
    Views:
    628
    David Segall
    Jan 22, 2011
Loading...

Share This Page