You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Ian McMeans <im...@telus.net> on 2002/07/03 02:54:15 UTC

python script and CGI

I've got a python script that I can't get to work. The script works when
called from command line, but not when called as a CGI program. I'm running
apache 2 and python 2.2, here is the script.

###############
#!/bin/python
import urllib2, cgi, cgitb
cgitb.enable()

print "Content-Type: text/html\n"     # HTML is following

print urllib2.urlopen('http://google.com/').read()
################

I can make other scripts work in apache, for example if the last line of the
script is replaced by "print 'hello'", then it works. So I've got no idea
why this script doesn't work.  Does anyone have any idea?

The script works from console, similar scripts work in CGI. Is python unable
to open connections from apache, or something? I'm really stuck with this
problem.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: python script and CGI

Posted by Lee Fellows <lf...@4lane.com>.
On Tue, 2002-07-02 at 20:54, Ian McMeans wrote:
> I've got a python script that I can't get to work. The script works when
> called from command line, but not when called as a CGI program. I'm running
> apache 2 and python 2.2, here is the script.
> 
> ###############
> #!/bin/python
> import urllib2, cgi, cgitb
> cgitb.enable()
> 
> print "Content-Type: text/html\n"     # HTML is following
> 
> print urllib2.urlopen('http://google.com/').read()
> ################
> 
> I can make other scripts work in apache, for example if the last line of the
> script is replaced by "print 'hello'", then it works. So I've got no idea
> why this script doesn't work.  Does anyone have any idea?
> 
> The script works from console, similar scripts work in CGI. Is python unable
> to open connections from apache, or something? I'm really stuck with this
> problem.
> 
> 
  What does happen?  What do you see in the error_log?




---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org