Error when python script run as cgi script

S

sophie_newbie

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.
 
D

Dennis Lee Bieber

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 address removed) (e-mail address removed)
HTTP://wlfraed.home.netcom.com/
(Bestiaria Support Staff: (e-mail address removed))
HTTP://www.bestiaria.com/
 
S

sophie_newbie

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 address removed) (e-mail address removed)
HTTP://wlfraed.home.netcom.com/
(Bestiaria Support Staff: (e-mail address 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?
 
D

Dennis Lee Bieber

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 address removed) (e-mail address removed)
HTTP://wlfraed.home.netcom.com/
(Bestiaria Support Staff: (e-mail address removed))
HTTP://www.bestiaria.com/
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top