Passing cgi parameters to script...

Discussion in 'Python' started by sophie_newbie, Dec 29, 2005.

  1. Is there any way that I can pass cgi parameters to my script locally,
    before i upload it to the webserver, so that i can debug it.

    Normally I would pass parameters like this:

    www.webserver.com/script.cgi?TERM1=hello&FIELD1=TTL&TERM2=goodby&FIELD2=GOVT

    The problem is that I get errors that do not show up when I run the
    script locally and I do not have access to the error logs.

    So is there a way I can pass the form values TERM1, FIELD1 etc to the
    script without having to upload it to the server?
     
    sophie_newbie, Dec 29, 2005
    #1
    1. Advertising

  2. sophie_newbie wrote:

    > Is there any way that I can pass cgi parameters to my script locally,
    > before i upload it to the webserver, so that i can debug it.
    >
    > Normally I would pass parameters like this:
    >
    >

    www.webserver.com/script.cgi?TERM1=hello&FIELD1=TTL&TERM2=goodby&FIELD2=GOVT
    >
    > The problem is that I get errors that do not show up when I run the
    > script locally and I do not have access to the error logs.
    >
    > So is there a way I can pass the form values TERM1, FIELD1 etc to the
    > script without having to upload it to the server?



    You might think of using CGIHttpServer to test your scripts in a
    server-environment - while still being local.

    Regards,

    Diez
     
    Diez B. Roggisch, Dec 29, 2005
    #2
    1. Advertising

  3. sophie_newbie

    Mike Meyer Guest

    "sophie_newbie" <> writes:
    > Is there any way that I can pass cgi parameters to my script locally,
    > before i upload it to the webserver, so that i can debug it.
    >
    > Normally I would pass parameters like this:
    >
    > www.webserver.com/script.cgi?TERM1=hello&FIELD1=TTL&TERM2=goodby&FIELD2=GOVT


    CGI paramaters are set in the environment. On Unix, in an sh-like
    shell, do:

    QUERY_STRING='TERM1=hello&FIELD1=TTL&TERM2=goodby&FIELD2=GOVT' www.webserver.com/script.cgi

    Depending on the package you're using for handling CGI, you may need
    to set other CGI parameters as well. The traceback from trying this
    should give you a KeyError naming the environment variable it's
    looking for.

    <mike
    --
    Mike Meyer <> http://www.mired.org/home/mwm/
    Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
     
    Mike Meyer, Dec 29, 2005
    #3
  4. sophie_newbie

    Kent Johnson Guest

    Diez B. Roggisch wrote:
    > sophie_newbie wrote:
    >
    >>Is there any way that I can pass cgi parameters to my script locally,
    >>before i upload it to the webserver, so that i can debug it.

    >
    > You might think of using CGIHttpServer to test your scripts in a
    > server-environment - while still being local.


    Which can be as simple as typing
    python -c "import CGIHTTPServer; CGIHTTPServer.test()"

    from the command line in the root dir of your site (the dir that
    contains the cgi-bin dir).

    Kent
     
    Kent Johnson, Dec 30, 2005
    #4
    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. lievemario
    Replies:
    2
    Views:
    748
    lievemario
    Nov 23, 2004
  2. Ramon F Herrera
    Replies:
    8
    Views:
    498
    Pascal J. Bourguignon
    Sep 13, 2009
  3. Francis Hwang
    Replies:
    2
    Views:
    133
    Francis Hwang
    Oct 7, 2004
  4. lievemario

    passing parameters from xsl to cgi script

    lievemario, Nov 23, 2004, in forum: Perl Misc
    Replies:
    4
    Views:
    152
    Andrew Tkachenko
    Nov 23, 2004
  5. kath
    Replies:
    4
    Views:
    722
    J. Gleixner
    Apr 9, 2007
Loading...

Share This Page