LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
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, 10: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, 10:48 AM   #2
matthewg42
Senior Member
 
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530

Rep: Reputation: 65
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, 12: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, 01: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 01:04 PM.
 
Old 12-09-2007, 01:19 PM   #5
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
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 01:23 PM.
 
Old 12-09-2007, 01:34 PM   #6
matthewg42
Senior Member
 
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530

Rep: Reputation: 65
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



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 08:51 PM
Running program in GUI opens term window zer0hmz Linux - Newbie 2 08-05-2006 02:36 AM
How can a bash script findout the width of the terminal window alex.e.c Linux - Software 2 10-14-2004 11:20 AM
bash script - open new window running a command zippity Linux - Newbie 1 07-13-2004 11:16 AM
Can't read term window dawhoo Linux - Newbie 1 12-21-2001 07:19 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 05:18 AM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration