-   Linux - Newbie (
-   -   Trying to launch a new term window while executing a bash script in that window (

sfmadmax 12-09-2007 10:19 AM

Trying to launch a new term window while executing a bash script in that window
Hey all,

I'm running into a snag here,

I wrote a script and want this script to run in a new terminal window everytime its executed.

Does anyone have any examples of this?


matthewg42 12-09-2007 10:48 AM

Assuming you are running it from an interactive shell where the DISPLAY is correctly set, it should just be a matter of invoking the name of your favourite terminal emulator. For example, here I start an xterm with a manual page being viewed in it (note that xterm has the -e option which means "execute the following command in the shell"):


xterm -e man ls
echo "Now the xterm has terminated we can continue..."

sfmadmax 12-09-2007 12:57 PM

Thanks for the reply, I managed to get it working,

the script has a case statement in it, After Input my selection the xterm quits almost immediately and does not let me see the output... Any way to stop that from occuring??

If I run the script in a regular window I see the output just fine.


sfmadmax 12-09-2007 01:01 PM

Yea I tried it with gnome-terminal --execute as well.. no luck

colucix 12-09-2007 01:19 PM

You can keep the xterm open by the -hold option, e.g.

xterm -hold -e ls
or - if you want to interact with the open shell

xterm -e "ls ; bash"
I don't have a gnome-terminal at hand (running KDE now) but there should be a similar option. In konsole (KDE terminal) it is --noclose.

matthewg42 12-09-2007 01:34 PM

Or like this if you don't want to give the user a working shell:

xterm -e "ls ; echo ''; echo press RETURN to close this window ; read"

All times are GMT -5. The time now is 04:51 PM.