LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (http://www.linuxquestions.org/questions/linux-general-1/)
-   -   Open Command In New Terminal Window (http://www.linuxquestions.org/questions/linux-general-1/open-command-in-new-terminal-window-573267/)

nuxeon 07-29-2007 11:44 PM

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?

macemoneta 07-30-2007 12:33 AM

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 &


nuxeon 08-01-2007 12:24 AM

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.

laurasong 08-06-2007 06:05 PM

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

macemoneta 08-06-2007 06:18 PM

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.

laurasong 08-08-2007 02:04 PM

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!

macemoneta 08-08-2007 02:47 PM

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.

laurasong 08-09-2007 01:03 PM

It works very well, Thanks a lot!


All times are GMT -5. The time now is 01:57 AM.