LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (http://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Trying to launch a new term window while executing a bash script in that window (http://www.linuxquestions.org/questions/linux-newbie-8/trying-to-launch-a-new-term-window-while-executing-a-bash-script-in-that-window-605602/)

sfmadmax 12-09-2007 11: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?

Thanks
-sean

matthewg42 12-09-2007 11: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"):
Code:

#!/bin/bash

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


sfmadmax 12-09-2007 01: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.

-Sean

sfmadmax 12-09-2007 02:01 PM

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

colucix 12-09-2007 02:19 PM

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

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

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 02:34 PM

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

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


All times are GMT -5. The time now is 03:20 AM.