I am trying to run R from an apache C++ module in a shell script to
plot some data to display it in apache later. I get the error
(reported in apache's logs):
Xlib: connection to ":0.0" refused by server
Xlib: No protocol specified
Error in X11(paste("png::", filename, sep = ""), width,
height, pointsize, :
unable to start device PNG
In addition: Warning message:
unable to open connection to X11 display`'
Execution halted
Is anyone familiar with this (i.e. running R from a non-X
environment)? Is there a way to get around this? I've seen some stuff
about virtual devices, but have no idea if it works or where to
start. If there is a simpler solution, please let me know.
-- doktora
I run the following shell script from the apache module using execve:
------------------------------------------------------
DISPLAY=:0.0
export DISPLAY
if $R --vanilla --quiet < $rfile >$log ; then
echo "Success"
else
echo "There were errors in $0, see $log"
fi
------------------------------------------------------
And $rfile contains this:
------------------------------------------------------
png(filename = "/tmp/plot.png", width = 510, height = 360);
plot(<some graph>)
dev.off()
See http://cran.us.r-project.org/doc/FAQ/R-FAQ.html#How-do-I-produce-PNG-graphic s-in-batch-mode_003f Andy> From: doktora v > > I am trying to run R from an apache C++ module in a shell script to > plot some data to display it in apache later. I get the error > (reported in apache's logs): > > Xlib: connection to ":0.0" refused by server > Xlib: No protocol specified > Error in X11(paste("png::", filename, sep = ""), width, > height, pointsize, : > unable to start device PNG > In addition: Warning message: > unable to open connection to X11 display`' > Execution halted > > Is anyone familiar with this (i.e. running R from a non-X > environment)? Is there a way to get around this? I've seen some stuff > about virtual devices, but have no idea if it works or where to > start. If there is a simpler solution, please let me know. > > -- doktora > > > I run the following shell script from the apache module using execve: > ------------------------------------------------------ > DISPLAY=:0.0 > export DISPLAY > > if $R --vanilla --quiet < $rfile >$log ; then > echo "Success" > else > echo "There were errors in $0, see $log" > fi > ------------------------------------------------------ > > And $rfile contains this: > ------------------------------------------------------ > png(filename = "/tmp/plot.png", width = 510, height = 360); > plot(<some graph>) > dev.off() > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! > http://www.R-project.org/posting-guide.html > >
On Mon, 2004-12-13 at 12:25 -0500, doktora v wrote:> I am trying to run R from an apache C++ module in a shell script to > plot some data to display it in apache later. I get the error > (reported in apache's logs): > > Xlib: connection to ":0.0" refused by server > Xlib: No protocol specified > Error in X11(paste("png::", filename, sep = ""), width, height, pointsize, : > unable to start device PNG > In addition: Warning message: > unable to open connection to X11 display`' > Execution halted > > Is anyone familiar with this (i.e. running R from a non-X > environment)? Is there a way to get around this? I've seen some stuff > about virtual devices, but have no idea if it works or where to > start. If there is a simpler solution, please let me know.I use the following when I need to plot a graphic by calling R from a PHP script on my webserver bitmap(file=plotfile, height=7, width=7) par(pch=19, col='black', cex=1.5) plot(log(1/boxsize), log(bv), ylab="log(box count)", xlab="log(1/box size)") ------------------------------------------------------------------- Rajarshi Guha <rxg218 at psu.edu> <http://jijo.cjb.net> GPG Fingerprint: 0CCA 8EE2 2EEB 25E2 AB04 06F7 1BB9 E634 9B87 56EE ------------------------------------------------------------------- A list is only as strong as its weakest link. -- Don Knuth
On Mon, 2004-12-13 at 12:25 -0500, doktora v wrote:> I am trying to run R from an apache C++ module in a shell script to > plot some data to display it in apache later. I get the error > (reported in apache's logs): > > Xlib: connection to ":0.0" refused by server > Xlib: No protocol specified > Error in X11(paste("png::", filename, sep = ""), width, height, pointsize, : > unable to start device PNG > In addition: Warning message: > unable to open connection to X11 display`' > Execution haltedI use the following when I need to plot a graphic by calling R from a PHP script on my webserver bitmap(file=plotfile, height=7, width=7) par(pch=19, col='black', cex=1.5) plot(log(1/boxsize), log(bv), ylab="log(box count)", xlab="log(1/box size)") ------------------------------------------------------------------- Rajarshi Guha <rxg218 at psu.edu> <http://jijo.cjb.net> GPG Fingerprint: 0CCA 8EE2 2EEB 25E2 AB04 06F7 1BB9 E634 9B87 56EE ------------------------------------------------------------------- Science kind of takes the fun out of the portent business. -Hobbes
On Mon, Dec 13, 2004 at 12:25:01PM -0500, doktora v wrote:> Is anyone familiar with this (i.e. running R from a non-X > environment)? Is there a way to get around this? I've seen some stuff > about virtual devices, but have no idea if it works or where to > start. If there is a simpler solution, please let me know.I've used Xvfb in this situation. After installing Xvfb, you can do something like this: Xvfb :15& export DISPLAY=localhost:15 # Run R + seth