Error when python script run as cgi script

Discussion in 'Python' started by sophie_newbie, Oct 21, 2007.

  1. 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.
     
    sophie_newbie, Oct 21, 2007
    #1
    1. Advertising

  2. On Sun, 21 Oct 2007 09:50:54 -0700, sophie_newbie
    <> 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://wlfraed.home.netcom.com/
    (Bestiaria Support Staff: )
    HTTP://www.bestiaria.com/
     
    Dennis Lee Bieber, Oct 21, 2007
    #2
    1. Advertising

  3. On Oct 21, 7:28 pm, Dennis Lee Bieber <> wrote:
    > On Sun, 21 Oct 2007 09:50:54 -0700, sophie_newbie
    > <> 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://wlfraed.home.netcom.com/
    > (Bestiaria Support Staff: )
    > 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?
     
    sophie_newbie, Oct 22, 2007
    #3
  4. On Mon, 22 Oct 2007 04:09:31 -0700, sophie_newbie
    <> 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

    HTTP://wlfraed.home.netcom.com/
    (Bestiaria Support Staff: )
    HTTP://www.bestiaria.com/
     
    Dennis Lee Bieber, Oct 22, 2007
    #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. praba kar

    Python-cgi or Perl-cgi script doubt

    praba kar, Jul 30, 2005, in forum: Python
    Replies:
    1
    Views:
    813
    Michael Sparks
    Jul 30, 2005
  2. Replies:
    1
    Views:
    357
    Larry Bates
    Dec 14, 2006
  3. excord80
    Replies:
    17
    Views:
    870
    J Kenneth King
    Jan 29, 2009
  4. fatted
    Replies:
    1
    Views:
    182
    Steve Grazzini
    Jul 25, 2003
  5. kath
    Replies:
    4
    Views:
    815
    J. Gleixner
    Apr 9, 2007
Loading...

Share This Page