LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices



Reply
 
Search this Thread
Old 07-29-2007, 11:44 PM   #1
nuxeon
LQ Newbie
 
Registered: Jul 2007
Posts: 6

Rep: Reputation: 0
Open Command In New Terminal Window


Hi There sorry for reposting this I kinda miscategorized the last one

Im tring to open 4 different xterm windows with different commands in them from one script. Anybody know how to do this?
 
Old 07-30-2007, 12:33 AM   #2
macemoneta
Senior Member
 
Registered: Jan 2005
Location: Manalapan, NJ
Distribution: Fedora x86 and x86_64, Debian PPC and ARM, Android
Posts: 4,593
Blog Entries: 2

Rep: Reputation: 328Reputation: 328Reputation: 328Reputation: 328
From 'man xterm':

Quote:
-e program [ arguments ... ]
This option specifies the program (and its command line argu-
ments) to be run in the xterm window. It also sets the window
title and icon name to be the basename of the program being
executed if neither -T nor -n are given on the command line.
This must be the last option on the command line.
So, for example:

Code:
#!/bin/bash
xterm -e command1 &
xterm -e command2 &
xterm -e command3 &
xterm -e command4 &
 
Old 08-01-2007, 12:24 AM   #3
nuxeon
LQ Newbie
 
Registered: Jul 2007
Posts: 6

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by macemoneta
From 'man xterm':



So, for example:

Code:
#!/bin/bash
xterm -e command1 &
xterm -e command2 &
xterm -e command3 &
xterm -e command4 &

Thank you much. Thats just what I was looking for. Shortly after reading this I also found out how to do it in gnome-term. Anways thanks agian it helped alot.
 
Old 08-06-2007, 06:05 PM   #4
laurasong
LQ Newbie
 
Registered: Aug 2007
Posts: 9

Rep: Reputation: 0
open commands in new xterms

Quote:
Originally Posted by macemoneta
From 'man xterm':



So, for example:

Code:
#!/bin/bash
xterm -e command1 &
xterm -e command2 &
xterm -e command3 &
xterm -e command4 &
I fond this email posting while searching solutions to the problem I have while tring to execute commands in new xterms from script. I my script I wrote:

xterm -e ls &
xterm -e date &
xterm -e pwd &

When I run the script, it opened up three terminals but they fade away, I'm not sure whether they has excuted commands. Any idea?

thanks,
Laura
 
Old 08-06-2007, 06:18 PM   #5
macemoneta
Senior Member
 
Registered: Jan 2005
Location: Manalapan, NJ
Distribution: Fedora x86 and x86_64, Debian PPC and ARM, Android
Posts: 4,593
Blog Entries: 2

Rep: Reputation: 328Reputation: 328Reputation: 328Reputation: 328
Quote:
Originally Posted by laurasong
I fond this email posting while searching solutions to the problem I have while tring to execute commands in new xterms from script. I my script I wrote:

xterm -e ls &
xterm -e date &
xterm -e pwd &

When I run the script, it opened up three terminals but they fade away, I'm not sure whether they has excuted commands. Any idea?

thanks,
Laura
The problem is that the commands that you are running end. When the command ends, the window closes. If you want to run this type of command and keep the window open, you can force a bash prompt. For example:

Code:
xterm -e ls\;bash &
The ';' separates commands, so the above issues two commands: 'ls' and 'bash'. The ';' has a backslash in front of it, because we want to send the ';' to xterm, not use it to end the xterm command.
 
Old 08-08-2007, 02:04 PM   #6
laurasong
LQ Newbie
 
Registered: Aug 2007
Posts: 9

Rep: Reputation: 0
Thanks a lot, I've tried it and it worked with xterm. I have changed my script to use gnome-terminal instead of xterm, somehow bash command won't work with gnome-terminal, I wonder why?

Thanks a lot!
 
Old 08-08-2007, 02:47 PM   #7
macemoneta
Senior Member
 
Registered: Jan 2005
Location: Manalapan, NJ
Distribution: Fedora x86 and x86_64, Debian PPC and ARM, Android
Posts: 4,593
Blog Entries: 2

Rep: Reputation: 328Reputation: 328Reputation: 328Reputation: 328
Quote:
Originally Posted by laurasong
Thanks a lot, I've tried it and it worked with xterm. I have changed my script to use gnome-terminal instead of xterm, somehow bash command won't work with gnome-terminal, I wonder why?
Thanks a lot!
Gnome-terminal works differently from xterm. The easiest way to do this with gnome-terminal is, for example:

Code:
gnome-terminal -e "bash -c ls\;bash"
This says to run gnome-terminal and pass it the command "bash". The bash command will be passed the option "-c" which causes it ro run the commands "ls" followed by bash as in the earlier xterm example.
 
Old 08-09-2007, 01:03 PM   #8
laurasong
LQ Newbie
 
Registered: Aug 2007
Posts: 9

Rep: Reputation: 0
It works very well, Thanks a lot!
 
  


Reply

Tags
xterm


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 On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
cannot open terminal window hairycandle Linux - Newbie 4 08-17-2006 12:42 PM
HOW TO OPEN UP A TERMINAL WINDOW?...any help will do..PLEASE! dhyaan Linux - General 18 04-05-2006 07:20 PM
keeping the terminal window open NNP Linux - General 1 09-02-2005 12:08 AM
how do I open a nautilus window when I'm in a terminal cjennings Linux - General 2 07-27-2004 01:41 PM
ping command in terminal window devindude Linux - Newbie 6 03-09-2004 05:03 PM


All times are GMT -5. The time now is 10:35 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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration