Calling R from a non-X shell script to plot?
Seth Falcon wrote:
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
FWIW, here's what I've used in the past for an Xvfb init script:
8<------------------------------------
#!/bin/bash
#
# syslog Starts Xvfb.
#
#
# chkconfig: 2345 12 88
# description: Xvfb is a facility that applications requiring an X frame
buffer \
# can use in place of actually running X on the server
# Source function library.
. /etc/init.d/functions
[ -f /usr/X11R6/bin/Xvfb ] || exit 0
XVFB="/usr/X11R6/bin/Xvfb :5 -screen 0 1024x768x16"
RETVAL=0
umask 077
start() {
echo -n $"Starting Xvfb: "
$XVFB&
RETVAL=$?
echo_success
echo
[ $RETVAL = 0 ] && touch /var/lock/subsys/Xvfb
return $RETVAL
}
stop() {
echo -n $"Shutting down Xvfb: "
killproc Xvfb
RETVAL=$?
echo
[ $RETVAL = 0 ] && rm -f /var/lock/subsys/Xvfb
return $RETVAL
}
restart() {
stop
start
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart|reload)
restart
;;
condrestart)
[ -f /var/lock/subsys/Xvfb ] && restart || :
;;
*)
echo $"Usage: $0 {start|stop|restart|condrestart}"
exit 1
esac
exit $RETVAL
8<-----------------------------------------
HTH,
Joe