[Ccing the list] On Tue, Sep 10, 2002 at 09:21:01PM -0400, Maitland Bottoms wrote: > On # Mon, 9 Sep 2002 15:34:45 -0500, Branden Robinson wrote: > >Yikes, a brief look at xvfb-run reveals syntax errors in it. > > > >I'll fix it up for 4.2.1-0pre1v2; let me know if that one works > >better. > > Feel free to send me an email of an updated xvfb-run, since it is > small and easy to send. No need to wait for 4.2.1-0pre1v2 unless you > think there is some issue with Xvfb itself.
Here you go. The tool and its manpage are attached. I've done some testing, but not thorough testing. Please let me know if you have any problems with it. -- G. Branden Robinson | If you have the slightest bit of Debian GNU/Linux | intellectual integrity you cannot [EMAIL PROTECTED] | support the government. http://people.debian.org/~branden/ | -- anonymous
#!/bin/sh # xvfb-run - run the specified command in a virtual X server # This script starts an instance of Xvfb, the "fake" X server, runs a # command with that server available, and kills the X server when # done. The return value of the command becomes the return value of # this script. # # If anyone is using this to build a Debian package, make sure the # package Build-Depends on xvfb, xbase-clients, and xfonts-base. set -e PROGNAME=xvfb-run SERVERNUM=99 AUTHFILE=$(pwd)/.Xauthority ERRORFILE=/dev/null STARTWAIT=3 LISTENTCP="-nolisten tcp" XAUTHPROTO=. # display a usage message usage () { cat << EOF Usage: $PROGNAME [OPTION ...] command run specified X client or command in a virtual X server environment -a --auto-servernum try to get a free server number, starting at --server-num -e FILE --error-file=FILE file used to store xauth errors and Xvfb output (defualt: $ERRORFILE) -f FILE --auth-file=FILE file used to store auth cookie (default: ./.Xauthority) -h --help display this usage message and exit -n NUM --server-num=NUM server number to use (default: $SERVERNUM) -l --listen-tcp enable TCP port listening in the X server -p PROTO --xauth-protocol=PROTO X authority protocol name to use (defaults to xauth's default) -w DELAY --wait=DELAY delay in seconds to wait for Xvfb to start (default: $STARTWAIT) EOF :; } # find free server number by looking at .X*-lock files in /tmp find_free_servernum() { i=$SERVERNUM while [ -f /tmp/.X$i-lock ]; do i=$(($i + 1)) done echo $i; } # parse command line ARGS=$(getopt --options +ae:f:hn:lp:w: \ --long auto-servernum,authority-file:,server-num:error-file:,help,listen-tcp,wait:,xauth-protocol: \ --name "$PROGNAME" -- "$@") if [ $? -ne 0 ]; then echo "$PROGNAME: error while getting options" >&2 exit 1 fi eval set -- "$ARGS" while :; do case "$1" in -a|--auto-servernum) SERVERNUM=$(find_free_servernum) ;; -e|--error-file) ERRORFILE="$1"; shift ;; -f|--auth-file) AUTHFILE="$1"; shift ;; -h|--help) SHOWHELP=1 ;; -n|--server-num) SERVERNUM="$1"; shift ;; -l|--listen-tcp) LISTENTCP="" ;; -p|--xauth-protocol) XAUTHPROTO="$1"; shift ;; -w|--wait) STARTWAIT="$1"; shift ;; --) shift; break ;; *) echo "$PROGNAME: error while parsing option \"$1\"" >&2; USAGE=$(usage); echo "$USAGE" >&2; exit 1 ;; esac shift done if [ "$SHOWHELP" ]; then usage exit 0 fi if [ -z "$*" ]; then echo "$PROGNAME: need a command to run" >&2 exit 2 fi if ! which xauth > /dev/null; then echo "$PROGNAME: xauth command not found; exiting." >&2 exit 3 fi # start Xvfb rm -f $AUTHFILE MCOOKIE=$(mcookie) XAUTHORITY=$AUTHFILE xauth add :$SERVERNUM $XAUTHPROTO $MCOOKIE > $ERRORFILE 2>&1 XAUTHORITY=$AUTHFILE Xvfb :$SERVERNUM -screen 0 640x480x8 $LISTENTCP > $ERRORFILE 2>&1 & XVFBPID=$! sleep $STARTWAIT # start the command and save its exit status set +e DISPLAY=:$SERVERNUM XAUTHORITY=$AUTHFILE $@ 2>&1 RETVAL=$? set -e # kill Xvfb now that the command has exited kill $XVFBPID # clean up XAUTHORITY=$AUTHFILE xauth remove :$SERVERNUM > $ERRORFILE 2>&1 rm $AUTHFILE # return the executed command's exit status exit $RETVAL # vim:set ai et sts=4 sw=4 tw=0:
.\" This manpage is copyright (C) 1998,1999,2000,2001 Branden Robinson .\" <[EMAIL PROTECTED]>. .\" .\" This is free software; you may redistribute it and/or modify .\" it under the terms of the GNU General Public License as .\" published by the Free Software Foundation; either version 2, .\" or (at your option) any later version. .\" .\" This is distributed in the hope that it will be useful, but .\" WITHOUT ANY WARRANTY; without even the implied warranty of .\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the .\" GNU General Public License for more details. .\" .\" You should have received a copy of the GNU General Public License .\" along with the Debian GNU/Linux system; if not, write to the Free .\" Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA .\" 02111-1307 USA .TH xvfb\-run 1 "2002\-09\-09" "Debian GNU/Linux" .SH NAME xvfb\-run \- run specified X client or command in a virtual X server environment .SH SYNOPSIS xvfb\-run [ .I options ] .I command .SH DESCRIPTION .B xvfb\-run is a wrapper for the .BR Xvfb (1x) command which simplifies the task of running commands (typically an X client, or a script containing a list of clients to be run) within a virtual X server environment. .PP .B xvfb\-run sets up an X authority file, writes a cookie to it (see .BR xauth (1x)) and then starts an Xvfb server as a background process. The process ID of .B Xvfb is stored for later use. The specified .I command is then run using the X display corresponding to the Xvfb server just started and the X authority file created earlier. .PP When the .I command exits, its status is saved, the .B Xvfb server is killed (using the process ID stored earlier), the X authority cookie removed, and the authority file deleted. .B xvfb\-run then exits with the exit status of .IR command. .PP .B xvfb\-run requires the .BR xauth (1x) command to function. .SH OPTIONS .TP .B \-a, \-\-auto\-servernum Try to get a free server number, starting at 99, or the argument to .BR \-\-server\-num . .TP .BI \-e\ file ,\ \-\-error\-file= file Store output from .BR xauth (1x) and .BR Xvfb (1x) in .IR file . If not set, output is sent to .IR /dev/null . .TP .BI \-f\ file ,\ \-\-auth\-file= file Store X authentication data in .IR file . By default, a file named .I .Xauthority in the current working directory is used. .TP .B \-h, \-\-help Display a usage message and exit. .TP .BI \-n\ servernumber ,\ \-\-server\-num= servernumber Use .I servernumber as the server number (but see the .B \-a, \-\-auto\-servernum option above). This value defaults to 99. .TP .B \-l, \-\-listen\-tcp Enable TCP port listening in the X server. .TP .BI \-p\ protocolname ,\ \-\-xauth\-protocol= protocolname Use .I protocolname as the X authority protocol to use. This defaults to \(oq.\(cq, which .BR xauth (1x) interprets as its own default protocol, which is MIT-MAGIC-COOKIE-1. .TP .BI \-w\ delay ,\ \-\-wait= delay Wait .I delay seconds after launching .BR Xvfb (1x) before attempting to start the specified command. Defaults to 3. .SH ENVIRONMENT None. .SH INPUT FILES None. .SH OUTPUT FILES .TP .I .Xauthority is created (and deleted) in the current working directory to store the X authority cookies used by the .B Xvfb server and client(s) run under it. .PP An error file with a user\-specified name is also created if the .B \-e or .B \-\-error\-file options are specifed; see above. .SH DIAGNOSTICS .B xvfb\-run uses its exit status as well as output to standard error to communicate diagnostics. .TP 1 The command\-line options could not be processed. .TP 2 No command to run was specified. .TP 3 The .BR xauth (1x) command is not available. .SH SEE ALSO .BR Xvfb (1x), .BR xauth (1x) .SH AUTHOR .B xfvb\-run was written by Branden Robinson and Jeff Licquia for Progeny Linux Systems, Inc., and the Debian Project.
pgpZ0ATreQxt0.pgp
Description: PGP signature