[Tutor] passig parameter with CGI...

Jay Deiman jay at splitstreams.com
Thu Feb 26 18:39:11 CET 2009


Spencer Parker wrote:
> I am looking for a little instruction on how one would process a set of 
> parameters being sent to it through CGI.  I have a script that sends 
> info to another script that lives on another server.  The second script 
> would then process the information that is passed to it through a 
> parameters list in a URL.  It would then trigger the script to do some 
> things via XMLRPC.  I have the portion that connects to the XMLRPC 
> server, but not the 1st part.  I can send it a list of command line 
> parameters, but the spec has changed.  We want to do it with just curl 
> and send it parameters with a URL string.  Not really looking for direct 
> code...just some ideas on how this is done for the most part.  I looked 
> around, but nothing really fit what I wanted...mostly form 
> processing...thanks!

I assume the receiving script is going to be a cgi or something like
that.  It sounds like all you want to do here is construct a GET request
to send to a web server.

=====================
import urllib

options = {'optone': '1' , 'opttwo': '2' , 'optthree': '3'}
url = 'http://www.example.com/path/to/script.cgi?%s' % \
         urllib.urlencode(options)
u = urllib.urlopen(url)
# Here you can read the response if needs be
response = u.read()
u.close()
=====================

That's about it.

-- 
Jay Deiman

\033:wq!



More information about the Tutor mailing list