open multiple xterms with script

Polytropon freebsd at edvax.de
Tue Dec 2 00:35:53 PST 2008


On Tue, 2 Dec 2008 10:07:47 +0200, "Aggelidis Nikos" <aggelidis.news at gmail.com> wrote:
> hi to all the list,
> 
> i need some help... Is it possible to open four consoles as
> root(authenticate yourself once), in each one run a specific program
> and do this through a script? {bash or python).
> i want to open 4 xterms in the four corners of the screen. In 3 xterms
> i want to run specific applications needing root privileges and the
> last i want it for administrative purposes.
> 
> what i have so far:
> 
> sudo xterm -e "path/to/application1" &
> sudo xterm -e "path/to/application2" &
> sudo xterm -e "path/to/application3" &
> sudo xterm
> 
> But this approach has the following problems:
> 
> 1) i have only managed to get it to work as sudo not su
> 
> 2) i haven't managed to position the 4 terminals correctly
> in the 4 corners of the screen

Maybe this is a solution for you (or at least a point to start):

	#!/bin/sh
	xterm -geometry <blahblah> -title "App 1" -e su root -c "app1" &
	xterm -geometry <blahblah> -title "App 2" -e su root -c "app2" &
	xterm -geometry <blahblah> -title "App 3" -e su root -c "app3" &
	xterm -geometry <blahblah> -title "App 4" -e su root -c "app4" &	

The -geometry is set as ROWSxCOLS+X+Y, e. g. 80x25+0+0 for
the upper left corner. See "man xterm" for further options as
you could need them.



> 3) i want to be able to close and restart a single terminal.without
> running again the whole script (this i am not sure if it is even
> doable). For example if one of the applications hungs, then i want to
> be able to restart this application, without running the whole script
> again.

You could create a "wrapper script" that calls four scripts which
only start one of the four applications each.

~/bin/run_1:
	#!/bin/sh
	xterm -geometry <blahblah> -title "App 1" -e su root -c "app1" &

~/bin/run_2:
	#!/bin/sh
	xterm -geometry <blahblah> -title "App 2" -e su root -c "app2" &

~/bin/run_3:
	#!/bin/sh
	xterm -geometry <blahblah> -title "App 3" -e su root -c "app3" &

~/bin/run_4:
	#!/bin/sh
	xterm -geometry <blahblah> -title "App 4" -e su root -c "app4" &

~/bin/run_all:
	#!/bin/sh
	~/bin/run_1
	~/bin/run_2
	~/bin/run_3
	~/bin/run_4

Not very elegant and tidy, but should work. You could add some
checking to the first script mentioned so it gets a clue which
application is *not* running and restart it when called, not
starting those that are running again (second session).



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


More information about the freebsd-questions mailing list