open multiple xterms with script

Polytropon freebsd at
Wed Dec 3 05:36:23 PST 2008

On Wed, 3 Dec 2008 09:58:52 +0200, "Aggelidis Nikos" < at> wrote:
> some additional questions:
> 1) is there any way to give the root password once? i tried this:
> #!/bin/sh
> su root -c "\
> xterm -geometry 80x25 -title 'App 1' -e 'app1' &
> xterm -geometry 80x25 -title 'App 2' -e 'app2'\
> "
> but i get this:
> xterm Xt error: Can't open display: %s

Exactly. When you su root, $DISPLAY is not set, so you would have
to set it first, maybe like this:

	su root -c "\
		export DISPLAY=:0.0; \
		xterm -geometry 80x25 -title 'App 1' -e 'app1' &
		xterm -geometry 80x25 -title 'App 2' -e 'app2' \

> 2)
> Is there any way to
> instruct xterm not to close after the execution of the program?

You could do this:

	xterm -geometry 80x25 -title 'App 1' -e 'app1 ; csh' &

which would start your prefered dialog shell when "app1" has
finished. The dialog shell would run even if "app" fails (thatÄs
why I suggest using ; instead of &&).

> So basically the idea is open 4 terminals, execute a specific command
> inside them but if the command finishes or stops, the terminal stays
> {with a new prompt}.

This sould be able to be achieved using the example above.

>From Magdeburg, Germany
Happy FreeBSD user since 4.0
Andra moi ennepe, Mousa, ...

More information about the freebsd-questions mailing list