Shell command to open a terminal that runs a command

Solved
Julie -  
 Julie -
Good evening,

I am looking to code a small shell script that, when launched, will open several new terminals that will each run a command to display useful data for my work (hence the interest in keeping the "parent" terminal clean). However, I don't know what option to use with xterm to pass a command to the newly opened terminal.
Do you have any idea? Is this even possible? Thank you in advance for your time, I am just starting out with shell scripting.

Configuration: Linux / Chrome 20.0.1132.17

2 réponses

Layn35
 
Hi,

man xterm

-e program [ arguments ... ]
specifies the program (and its command line arguments) that should be launched in the xterm window. This option also sets the window title and icon name to the base name of the running program if neither -T nor -n are specified on the command line. It must be the last option on the xterm command line.

The -e option followed by the name of the command to execute will launch that command in the new window.

You can do something like:

#!/bin/sh
xterm -e "command 1" &
xterm -e "command 2" &
xterm -e "command 3" &
7
Julie
 
Thank you very much, that's exactly what I needed! I must have skimmed over this option while reading the man without understanding it, thank you for clarifying it.

Edit: After a few attempts, I realize that the open terminal only serves to execute a program and then closes. In my case, it needs to stay open since one of the commands to run is, for example:

cat /u/shared/$1/public/* | grep -n ERROR

So I need to have a response, which is not the case here since the terminal closes once the command is executed.
0
dubcek Posted messages 18702 Registration date   Status Contributeur Last intervention   5 657
 
hello
to keep the xterm open:
xterm -e "command; $SHELL" &
4
Julie
 
Thank you, everything is now working as I wanted!
Problem solved.
0