I need to run 3 different programs at different 'computers'. These computers are open in three different tabs in a terminal. How do I make a bash/python/?? script which can send three different commands to three different tabs. Thanks in advance.
-
What you mean 'computers'? Is it a `ssh` connections or what? – ДМИТРИЙ МАЛИКОВ Nov 16 '11 at 21:03
-
@dmitry.malikov Yes. computers means ssh connection to a remote host – user984260 Nov 16 '11 at 21:22
1 Answers
Edit To the comments:
gnome-terminal -e "bash -c 'ls *; echo hello world; ssh user@remote -XCt xterm'"
Note that this allows you to easily embed environment variables as well:
MESSAGE="goobye"
gnome-terminal -e "bash -c 'echo $MESSAGE'"
I'd use GNU screen:
screen -DRS mysession # starts the session with a given name
screen command1 # start the commands
screen command2
screen command3
Now there are numerous options to show many or all windows at once, to monitor for activity, to log a window's output, whatnot. You can even detach a session and reconnect to it, so if you leave your desktop, you can come back to your session by logging in to your PC using e.g. ssh, and just typing
screen -DRS mysession
again: you'll be back where you were, all three windows still active
Edit Oh, and since you asked:
screen -xS mysession
will view/share the same session (named mysession
) whithout detaching the other terminal. This makes it possible for you to share screens remotely, or show separate screens of the session in differen Xterm/gnome-terminals etc.
Some keybindings:
- Ctrl+ASpace next screen
- Ctrl+AS split horizontally
- Ctrl+A| split vertically
Ctrl+ATab focus to next visible window
Ctrl+AD detach (reattach with
screen -DR
)
Many many more features...
- Ctrl+A? feature help

- 374,641
- 47
- 450
- 633
-
Thanks a lot. However, My intention is to send multiple commands which will run on multiple servers and I want to automate it (since I do it a lot). Can you explain a bit more. – user984260 Nov 16 '11 at 21:35
-
No, I want to send different commands, e.g. A. run QEMU on Server1 B. run simplescalar on Server2 C. run M5 on Server3 – user984260 Nov 16 '11 at 21:45
-
Puppet looks to be a management tool. I am not sysadmin, just a user and want to use those servers – user984260 Nov 16 '11 at 21:50
-
Something like this is sufficient for me: gnome-terminal -e 'command "complex argument"' from http://stackoverflow.com/questions/6611542/opening-multiple-tabs-in-gnome-terminal-with-complex-commands-from-a-cycle Only thing is that I need to issue commands, which have their arguments. How to do that? – user984260 Nov 16 '11 at 21:54
-
Thanks. I found the answer. I need to use xterm -e ssh xyz1 to different terminals and that would do. Thanks for your timely help sehe. – user984260 Nov 16 '11 at 22:01
-