Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Error when python script run as cgi script

Reply
Thread Tools

Error when python script run as cgi script

 
 
sophie_newbie
Guest
Posts: n/a
 
      10-21-2007
Hi, I'm running a python script which if I run from the command line
as root runs fine. But if I run it through the web-browser as a cgi
script gives the following error "Error in X11: unable to start device
PNG".

Now I should say that this python script is calling fucntions in R (a
scripting languange used in statistics) using the python module RPy,
so this I dunno if this is entirely a Python question, because as far
as I can see the error is being thrown by R. But then as I say, when
the script is run by the root user from the command line everything
goes off without a hitch.

So I dunno is there some way to run a CGI script as root, maybe thats
a bad idea because of security? But any ideas would be welcome.

-Thanks.

 
Reply With Quote
 
 
 
 
Dennis Lee Bieber
Guest
Posts: n/a
 
      10-21-2007
On Sun, 21 Oct 2007 09:50:54 -0700, sophie_newbie
<(E-Mail Removed)> declaimed the following in comp.lang.python:

> Hi, I'm running a python script which if I run from the command line
> as root runs fine. But if I run it through the web-browser as a cgi
> script gives the following error "Error in X11: unable to start device
> PNG".
>
> Now I should say that this python script is calling fucntions in R (a
> scripting languange used in statistics) using the python module RPy,
> so this I dunno if this is entirely a Python question, because as far
> as I can see the error is being thrown by R. But then as I say, when
> the script is run by the root user from the command line everything
> goes off without a hitch.
>

Ah, but does it run if you boot into a NON-graphical command shell
mode...

That error message looks suspiciously like something is trying to
open a graphical display window... A web-server likely does not have any
graphical environment.
--
Wulfraed Dennis Lee Bieber KD6MOG
http://www.velocityreviews.com/forums/(E-Mail Removed) (E-Mail Removed)
HTTP://wlfraed.home.netcom.com/
(Bestiaria Support Staff: (E-Mail Removed))
HTTP://www.bestiaria.com/
 
Reply With Quote
 
 
 
 
sophie_newbie
Guest
Posts: n/a
 
      10-22-2007
On Oct 21, 7:28 pm, Dennis Lee Bieber <(E-Mail Removed)> wrote:
> On Sun, 21 Oct 2007 09:50:54 -0700, sophie_newbie
> <(E-Mail Removed)> declaimed the following in comp.lang.python:
>
> > Hi, I'm running a python script which if I run from the command line
> > as root runs fine. But if I run it through the web-browser as a cgi
> > script gives the following error "Error in X11: unable to start device
> > PNG".

>
> > Now I should say that this python script is calling fucntions in R (a
> > scripting languange used in statistics) using the python module RPy,
> > so this I dunno if this is entirely a Python question, because as far
> > as I can see the error is being thrown by R. But then as I say, when
> > the script is run by the root user from the command line everything
> > goes off without a hitch.

>
> Ah, but does it run if you boot into a NON-graphical command shell
> mode...
>
> That error message looks suspiciously like something is trying to
> open a graphical display window... A web-server likely does not have any
> graphical environment.
> --
> Wulfraed Dennis Lee Bieber KD6MOG
> (E-Mail Removed) (E-Mail Removed)
> HTTP://wlfraed.home.netcom.com/
> (Bestiaria Support Staff: (E-Mail Removed))
> HTTP://www.bestiaria.com/


Ya thanks looks like you're actually right. The strange thing is that
the program, when run from a graphical command line, doesn't actually
open any display window. Although the code doesn't run when executed
as a webserver, most likely, as you pointed out, because there is no
graphical environment. I wonder if there any way I can somehow enable
a graphical environment for the webserver, or do I have to re-write
the underlying code?

 
Reply With Quote
 
Dennis Lee Bieber
Guest
Posts: n/a
 
      10-22-2007
On Mon, 22 Oct 2007 04:09:31 -0700, sophie_newbie
<(E-Mail Removed)> declaimed the following in comp.lang.python:

> Ya thanks looks like you're actually right. The strange thing is that
> the program, when run from a graphical command line, doesn't actually
> open any display window. Although the code doesn't run when executed


I probably shouldn't have used the word "display"; what I meant to
imply was that the low-level is trying to use a graphical environment to
render something (a PNG image?) using a non-displayed/off-screen memory
block... The main factor being that it isn't drawing the image file
itself, but expecting to create the bitmap using the OS (in this case,
X-window) calls, and probably then doing a "screen grab" to get the
result into a file.

All this is hypothesis based upon the reported message. And it is
likely down in the level of the R source code, not at the Python level
(other than, perhaps, replacing R with something like NumPy/SciPy and
PIL).
--
Wulfraed Dennis Lee Bieber KD6MOG
(E-Mail Removed) (E-Mail Removed)
HTTP://wlfraed.home.netcom.com/
(Bestiaria Support Staff: (E-Mail Removed))
HTTP://www.bestiaria.com/
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
what's wrong calling a Perl/CGI script in Perl/CGI script under Tomcat server? kath Perl Misc 4 04-09-2007 09:21 PM
run a script and supply commands from a python cgi script moishyyehuda@gmail.com Python 1 12-14-2006 05:16 PM
cgi relay for python cgi script Amir Michail Python 7 10-04-2005 07:11 PM
Python-cgi or Perl-cgi script doubt praba kar Python 1 07-30-2005 08:25 AM
CGI module: getting cgi params from text file redirected to script run on the commandline fatted Perl Misc 1 07-25-2003 01:44 AM



Advertisments