PDA

View Full Version : shell script - open a new tab in terminal



Tex-Twil
July 25th, 2007, 07:29 AM
Hello,
I have a little shell script which launch some commands and I'd like to know if it's possible to open programmaticaly a new tab or terminal to launch each of the commands in a different window/tab.

Thank you

nichipet
July 25th, 2007, 08:25 AM
You might be able to do it so it opens them each in new instances of Terminal, but almost certainly not in tabs. Shell scripting basically works within the shell and is limited to there, so it cannot manipulate something outside of the shell, such as a GUI.

Tex-Twil
July 25th, 2007, 08:41 AM
ok I think this should work:


#!/bin/sh

gnome-terminal -e "ping www.free.fr"
gnome-terminal -e "ping www.google.fr"

Note360
July 25th, 2007, 04:25 PM
I would look into screen if I where you. It should do what you need. Its kinda like tabbing inside the terminal window.

mikec13
July 25th, 2007, 06:54 PM
You might be able to do it so it opens them each in new instances of Terminal, but almost certainly not in tabs. Shell scripting basically works within the shell and is limited to there, so it cannot manipulate something outside of the shell, such as a GUI.

If you want it in two different tabs you could do something like this:


gnome-terminal -e "ping www.free.fr" --tab -e "ping www.google.fr"

nichipet
July 25th, 2007, 07:52 PM
If you want it in two different tabs you could do something like this:


gnome-terminal -e "ping www.free.fr" --tab -e "ping www.google.fr"

Thanks for pointing that out. I use konsole mostly, it's good to learn something new about gnome-terminal.

Note360
July 26th, 2007, 03:09 AM
er every one ignored my suggestion of screen huh...

cwaldbieser
July 26th, 2007, 04:44 AM
Thanks for pointing that out. I use konsole mostly, it's good to learn something new about gnome-terminal.

You can probably use the "dcop" command to automate konsole. Try running "kdcop" and experiment sending messages to an open konsole (try the newSession method).