How to execute a command in newly open terminal(gnome-terminal) in scripting ?

Paul Sladen ubuntu at
Wed Jul 13 23:45:42 UTC 2011

On Wed, 13 Jul 2011, Amrit Pal Pathak wrote:
> It is opening the 3 terminals but only 2nd command is running others 2(1st
> and 3rd) are not.

Put an ampersand ('&') at the end of the line to run the comamnd in
the background.

>  Why?

When you do:

  command1 ; command2 ; command3

this runs the commands in series (one after the other, each waiting
for the previous, whereas:

  command1 & command2 & command3 &

will put all of them into the background, running them in parallel and
allowing you to continue with additional actions.

This 'multi-tasking' is one of the primary advantages that Unix had
have other operating system designs when it was designed.

> I need 3 commands to run into 3 terminals seprately

I actually do something quite similiar, but I use a 'screen' session
(see GNU Screen) with a '~/.screenrc' that starts IRC in one window,
text-based Email in another terminals in another.  Before the
existance of multi-server IRC clients, it actually started several IRC
clients in parallel screens, each talking to a different server.  
That bit is still there in the config file, commented out:

  #screen -t "#jxxxxx" 3 epic4 -n sladen -c \#jump
  #screen -t "#qxxxxx" 4 epic4 -n sladen -c \#quaker mxxxxxx.xxxx.xxxx
  #screen -t "#uxxxxx" 5 epic4 -n sladen -c \#uxxxxx

This allows having just one 'gnome-terminal' open, but with multiple
tasks within it and being able to 'alt-tab' between them using Ctrl-a.

Hope that's useful!


More information about the ubuntu-users mailing list