LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 12-09-2007, 11:19 AM   #1
sfmadmax
LQ Newbie
 
Registered: Dec 2007
Posts: 7

Rep: Reputation: 0
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
 
Old 12-09-2007, 11:48 AM   #2
matthewg42
Senior Member
 
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530

Rep: Reputation: 63
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..."
 
Old 12-09-2007, 01:57 PM   #3
sfmadmax
LQ Newbie
 
Registered: Dec 2007
Posts: 7

Original Poster
Rep: Reputation: 0
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
 
Old 12-09-2007, 02:01 PM   #4
sfmadmax
LQ Newbie
 
Registered: Dec 2007
Posts: 7

Original Poster
Rep: Reputation: 0
Yea I tried it with gnome-terminal --execute as well.. no luck

Last edited by sfmadmax; 12-09-2007 at 02:04 PM.
 
Old 12-09-2007, 02:19 PM   #5
colucix
Moderator
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957
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.

Last edited by colucix; 12-09-2007 at 02:23 PM.
 
Old 12-09-2007, 02:34 PM   #6
matthewg42
Senior Member
 
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530

Rep: Reputation: 63
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"
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
bash - how to launch a console window via script and execute commands in it? basd Programming 4 01-26-2008 09:51 PM
Running program in GUI opens term window zer0hmz Linux - Newbie 2 08-05-2006 03:36 AM
How can a bash script findout the width of the terminal window alex.e.c Linux - Software 2 10-14-2004 12:20 PM
bash script - open new window running a command zippity Linux - Newbie 1 07-13-2004 12:16 PM
Can't read term window dawhoo Linux - Newbie 1 12-21-2001 08:19 PM


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

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration