From owner-freebsd-questions@FreeBSD.ORG Tue Dec 2 08:35:52 2008 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E22EC1065672 for ; Tue, 2 Dec 2008 08:35:52 +0000 (UTC) (envelope-from freebsd@edvax.de) Received: from mx01.qsc.de (mx01.qsc.de [213.148.129.14]) by mx1.freebsd.org (Postfix) with ESMTP id B1FF58FC14 for ; Tue, 2 Dec 2008 08:35:52 +0000 (UTC) (envelope-from freebsd@edvax.de) Received: from r55.edvax.de (port-92-196-24-200.dynamic.qsc.de [92.196.24.200]) by mx01.qsc.de (Postfix) with ESMTP id 9D7713CB64; Tue, 2 Dec 2008 09:35:47 +0100 (CET) Received: from r55.edvax.de (localhost [127.0.0.1]) by r55.edvax.de (8.14.2/8.14.2) with SMTP id mB28Zi7t001593; Tue, 2 Dec 2008 09:35:44 +0100 (CET) (envelope-from freebsd@edvax.de) Date: Tue, 2 Dec 2008 09:35:44 +0100 From: Polytropon To: "Aggelidis Nikos" Message-Id: <20081202093544.a5cb8a21.freebsd@edvax.de> In-Reply-To: <30fc78250812020007h22ab0dc4if044e46b4f36b00c@mail.gmail.com> References: <30fc78250812020007h22ab0dc4if044e46b4f36b00c@mail.gmail.com> Organization: EDVAX X-Mailer: Sylpheed 2.4.7 (GTK+ 2.12.1; i386-portbld-freebsd7.0) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Cc: freebsd-questions@freebsd.org Subject: Re: open multiple xterms with script X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Polytropon List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 02 Dec 2008 08:35:53 -0000 On Tue, 2 Dec 2008 10:07:47 +0200, "Aggelidis Nikos" 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 -title "App 1" -e su root -c "app1" & xterm -geometry -title "App 2" -e su root -c "app2" & xterm -geometry -title "App 3" -e su root -c "app3" & xterm -geometry -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 -title "App 1" -e su root -c "app1" & ~/bin/run_2: #!/bin/sh xterm -geometry -title "App 2" -e su root -c "app2" & ~/bin/run_3: #!/bin/sh xterm -geometry -title "App 3" -e su root -c "app3" & ~/bin/run_4: #!/bin/sh xterm -geometry -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, ...