Dear all,
I am trying to create a web interface using Perl-CGI to call R plots and
to display them.
The following codes works perfectly fine when I copy and paste into the
console directly or if I save it into script.file and then R --no-save <
script.file producing the graphs.
jpeg("graph.jpeg", width=400, height=400)
plot(rnorm(100))
dev.off()
Now, I put the line system("R --no-save < script.file >
log_file") from
inside my cgi and then process it from client side, I get the following
error message:
Error in X11(paste("jpeg::", quality, ":", filename, sep =
""), width,
:
unable to start device JPEG
In addition: Warning message:
unable to open connection to X11 display`'
Execution halted
Why do I get this error and how can I fix it? Many thanks in advance.
Regards, Adai.
Adai, I think this issue or something very related to it has come up before in this list, so you may wish to search the R-help mail archives. From what you say, my guess on the reason for the error is permissions related, as the web server (Apache?) executing your CGI does not implictly have access to an X resource, which jpeg needs to work. I have had some luck using "Xvfb" under Linux for CGI scripts with R to generate PNG format data graphs. But this is a work-in-progress, as I have not solved the permissions problem with a secure method yet. Plus there is the complication of cleanly accessing an X display in a multi-user system. You can learn much about Xvfb via google. Hope that helps, Bill ---------------------------------------- Bill Pikounis, Ph.D. Biometrics Research Department Merck Research Laboratories PO Box 2000, MailDrop RY84-16 126 E. Lincoln Avenue Rahway, New Jersey 07065-0900 USA v_bill_pikounis at merck.com Phone: 732 594 3913 Fax: 732 594 1565> -----Original Message----- > From: Adaikalavan Ramasamy [mailto:gisar at nus.edu.sg] > Sent: Monday, March 17, 2003 8:43 AM > To: r-help at stat.math.ethz.ch > Subject: [R] X11 connection error in web cgi mode only > > > Dear all, > > I am trying to create a web interface using Perl-CGI to call > R plots and > to display them. > The following codes works perfectly fine when I copy and > paste into the > console directly or if I save it into script.file and then R > --no-save < > script.file producing the graphs. > > jpeg("graph.jpeg", width=400, height=400) > plot(rnorm(100)) > dev.off() > > Now, I put the line system("R --no-save < script.file > > log_file") from > inside my cgi and then process it from client side, I get the > following > error message: > > > Error in X11(paste("jpeg::", quality, ":", filename, sep = ""), width, > : > unable to start device JPEG > In addition: Warning message: > unable to open connection to X11 display`' > Execution halted > > > Why do I get this error and how can I fix it? Many thanks in advance. > > Regards, Adai. > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://www.stat.math.ethz.ch/mailman/listinfo/r-help >------------------------------------------------------------------------------
I believe you get this error because the jpeg and png libraries require the X11 device to be open in order to generate the plot. I'll guess that if you're doing CGI then the X11 device is not available. You can try using the `bitmap' device if you want jpeg or png. This converts to jpeg/png from postscript. -roger _______________________________ UCLA Department of Statistics rpeng at stat.ucla.edu http://www.stat.ucla.edu/~rpeng On Mon, 17 Mar 2003, Adaikalavan Ramasamy wrote:> Dear all, > > I am trying to create a web interface using Perl-CGI to call R plots and > to display them. > The following codes works perfectly fine when I copy and paste into the > console directly or if I save it into script.file and then R --no-save < > script.file producing the graphs. > > jpeg("graph.jpeg", width=400, height=400) > plot(rnorm(100)) > dev.off() > > Now, I put the line system("R --no-save < script.file > log_file") from > inside my cgi and then process it from client side, I get the following > error message: > > > Error in X11(paste("jpeg::", quality, ":", filename, sep = ""), width, > : > unable to start device JPEG > In addition: Warning message: > unable to open connection to X11 display`' > Execution halted > > > Why do I get this error and how can I fix it? Many thanks in advance. > > Regards, Adai. > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://www.stat.math.ethz.ch/mailman/listinfo/r-help >
I had the some problem with some CGI and some perl program running on
SUN-SOLARIS.
At the first I left open an Xsession on my PC (NT4) adding on all programs
the followed lines:
$ENV{DISPLAY} = 'vfasciani:0.0';
In this way all programs ran well bacause they found my X11 service.
After, my system admin installed on my machine a Xvnc service
(www.realvnc.com) that allows to create graph.
Sorry but I'm not a deep UNIX user and for me is difficult explain all steps
to install it.
If you are interested I can send to you his email.
- Vittorio
_____________________
Vittorio Paolo Fasciani
Operation Software Technician
Micron Technology Italia
vfasciani at micron.com
_________________________
-----Original Message-----
From: Roger Peng [mailto:rpeng at stat.ucla.edu]
Sent: Monday, March 17, 2003 6:12 PM
To: Adaikalavan Ramasamy
Cc: r-help at stat.math.ethz.ch
Subject: Re: [R] X11 connection error in web cgi mode only
I believe you get this error because the jpeg and png libraries require
the X11 device to be open in order to generate the plot. I'll guess that
if you're doing CGI then the X11 device is not available. You can try
using the `bitmap' device if you want jpeg or png. This converts to
jpeg/png from postscript.
-roger
_______________________________
UCLA Department of Statistics
rpeng at stat.ucla.edu
http://www.stat.ucla.edu/~rpeng
On Mon, 17 Mar 2003, Adaikalavan Ramasamy wrote:
> Dear all,
>
> I am trying to create a web interface using Perl-CGI to call R plots and
> to display them.
> The following codes works perfectly fine when I copy and paste into the
> console directly or if I save it into script.file and then R --no-save <
> script.file producing the graphs.
>
> jpeg("graph.jpeg", width=400, height=400)
> plot(rnorm(100))
> dev.off()
>
> Now, I put the line system("R --no-save < script.file >
log_file") from
> inside my cgi and then process it from client side, I get the following
> error message:
>
>
> Error in X11(paste("jpeg::", quality, ":", filename,
sep = ""), width,
> :
> unable to start device JPEG
> In addition: Warning message:
> unable to open connection to X11 display`'
> Execution halted
>
>
> Why do I get this error and how can I fix it? Many thanks in advance.
>
> Regards, Adai.
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help
>
______________________________________________
R-help at stat.math.ethz.ch mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
According to my sysadmin I post his answer for all useRs.
-Vittorio
____________________
Vittorio Paolo Fasciani
Operation Software Technician
Micron Technology Italia
vfasciani at micron.com
_________________________
-----Original Message-----
From: eboriani
Sent: Wednesday, March 19, 2003 11:03 AM
To: 'v_bill_pikounis at merck.com'
Cc: vfasciani
Subject: RE: [R] X11 connection error in web cgi mode only
Bill,
in order to use vnc as an X11 server you need of:
- the vnc binary (or vnc source to compile n the server), generally you can
find the binary for the following path: /usr/local, you can find the binary
on the vnc web site (www.realvnc.com).
- appropriate settings to start the vncserver, a my script for vncserver
start/stop follow:
#!/bin/ksh
case "$1" in
'start')
# Start the X server deamon
PATH=$PATH:/usr/local/vnc:/usr/openwin/bin/
export PATH
HOME=/
export HOME
OPENWINHOME=/usr/openwin
export OPENWINHOME
/usr/local/vnc/vncserver
DISPLAY=unix:1.0
export DISPLAY
/usr/openwin/bin/xhost +host1 host2 ......
;;
'stop')
# Stop the X server deamon
PATH=$PATH:/usr/local/vnc:/usr/openwin/bin/
export PATH
/usr/local/vnc/vncserver -kill :1
;;
*)
echo "Usage: $0 { start | stop }"
exit 1
;;
esac
If all work fine you should see running a process like this:
root 29315 1 0 Jan 15 ? 164:32 Xvnc :1 -desktop X -auth
//.Xauthority -geometry 1024x768 -depth 16 -rfbwait 12
Let me know any issues.
Regards
--Ettore
-----Original Message-----
From: Adaikalavan Ramasamy [mailto:gisar at nus.edu.sg]
Sent: Monday, March 17, 2003 2:43 PM
To: r-help at stat.math.ethz.ch
Subject: [R] X11 connection error in web cgi mode only
Dear all,
I am trying to create a web interface using Perl-CGI to call R plots and
to display them.
The following codes works perfectly fine when I copy and paste into the
console directly or if I save it into script.file and then R --no-save <
script.file producing the graphs.
jpeg("graph.jpeg", width=400, height=400)
plot(rnorm(100))
dev.off()
Now, I put the line system("R --no-save < script.file >
log_file") from
inside my cgi and then process it from client side, I get the following
error message:
Error in X11(paste("jpeg::", quality, ":", filename, sep =
""), width,
:
unable to start device JPEG
In addition: Warning message:
unable to open connection to X11 display`'
Execution halted
Why do I get this error and how can I fix it? Many thanks in advance.
Regards, Adai.
______________________________________________
R-help at stat.math.ethz.ch mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help