Xaprb

Stay curious!

How to send input to many terminals

with 15 comments

Do you ever find yourself wanting to open several terminal windows and send the same commands to all of them? I’ve had this need many times, and I’ve never found a completely satisfactory solution. I’ve also known a lot of people who’ve written various sets of scripts to help them accomplish such tasks.

In no particular order, here are a few ways I’ve done this in the past:

  1. Facebook’s pmysql client
  2. The dsh tool
  3. Several screen windows named remoteXXX, followed by a bash for-loop: while read cmd; do screen -X at remote# stuff "$cmd"; done
  4. Using many PuTTY windows and the puttycs tool
  5. Opening many tabs in KDE’s Kterm tool and selecting the options to send input to all tabs

Here are some I’ve heard about, but never used:

  1. PolySH
  2. rcall
  3. A variety of “terminal multiplexor” web pages I’ve bookmarked

Of course, in many cases a technology like Chef or Puppet provides the true solution. But a lot of the MySQL users I’ve known haven’t grown to the point that they want to spend the upfront time and effort to learn and deploy something like that. They’re investing in development instead, and bearing the cost of a little less efficient systems administration process.

What’s your favorite technique for doing lots of things all at once?

Written by Xaprb

October 16th, 2012 at 8:53 am

Posted in SQL,Sys Admin,Tools

15 Responses to 'How to send input to many terminals'

Subscribe to comments with RSS

  1. On Terminator you can group windows and broadcast the command to the group

    Ivan

    16 Oct 12 at 9:03 am

  2. Puppet http://puppetlabs.com/ or
    pdsh (w/genders) https://code.google.com/p/pdsh/ or
    iTerm2 http://www.iterm2.com/ tab broadcast

    depending on context.

    Justin Honold

    16 Oct 12 at 10:21 am

  3. I use Xshell & it has a good option to send command to multiple terminals.

    Kedar

    16 Oct 12 at 11:00 am

  4. Cluster SSH! There is also csshx for Mac users.

    Michael Wehrle

    16 Oct 12 at 11:17 am

  5. Hi Baron,

    my preferred are:
    – mrxvt on Linux
    – iTerm2 on Mac

    both are sending output on all tabs on demand as well monitoring tabs for output (which is very useful when you tail -f on some error file, or console opened with in a tab)..

    Rgds,
    -Dimitri

    Dimitri

    16 Oct 12 at 11:41 am

  6. I’ve been using Terminator recently for doing testing on some distributed applications, and have been really impressed with it. The ability to create multiple color-coded groups of terminals and then broadcast commands to all terminals or just select groups has been an incredible timesaver.

    You’re right, it’s not what you should be doing for production deployment, but for a dev/test environment it’s a great tool.

    Jason

    16 Oct 12 at 11:51 am

  7. Terminator [http://www.tenshu.net/p/terminator.html]

    sw

    16 Oct 12 at 11:52 am

  8. Another suggestion is Ansible. It is also an orchestration framework like Chef or Puppet, but much much simpler to learn, understand, and use.
    http://ansible.github.com/

    I have been using it for 6 months now, and could not be happier. You can write playbooks to provision servers, or for single commands, there is an nice way to run it on multiple servers. Best of all, it all uses SSH, so there is nothing new to set up.

    Peter Sankauskas

    16 Oct 12 at 12:03 pm

  9. Oh yes, Terminator for me as well. I haven’t taken the time to learn on how to play with config files so the server names and grouping stick, but in a pinch, here is how to do it manually:

    1. Right click for terminal window vertical and/or horizontal split. You can open as many as you like;

    2. Open upper left menu, pick “New group”, name them such as Dev, QA, as appropriate;

    3. As you ssh into other servers, you can define which group that server(s) belong to. Now if you type in any terminal that belong to a group, the same command will be blasted to all other servers in that group, with the appropriate command output piped back.

    I’ve heard Konsole can do this, but never take the time to figure it out.

    Ji Village News

    16 Oct 12 at 1:17 pm

  10. Peter

    16 Oct 12 at 1:47 pm

  11. I like to use rutty, a ruby gem. If the client has a recent version of ruby installed. :)

    https://github.com/jlindsey/rutty

    Aaron Brown

    16 Oct 12 at 6:46 pm

  12. My favorite for manual commands is cluster-shell for Mac: csshx
    http://code.google.com/p/csshx/

    But for scripting or crons, dsh.

    I’m going to check out pmysql. Thanks for the tip!

    Valerie

    Valerie

    16 Oct 12 at 7:03 pm

  13. To go along with Valerie’s comment, I’ve used clusterssh for years.

    http://sourceforge.net/projects/clusterssh/

    BPK

    16 Oct 12 at 9:16 pm

  14. You should give saltstack a try: http://saltstack.com/

    It’s quite easy to pick up and the remote execution is *excellent*. The MySQL module is quite nice too:
    http://docs.saltstack.org/en/latest/ref/modules/all/salt.modules.mysql.html#module-salt.modules.mysql

    pcrews

    18 Oct 12 at 12:54 am

  15. The amount of ssh-in-a-for-loop-improved reminds me of the amount of flashlight apps in the Apple AppStore…

    http://docs.fabfile.org

    Daniël van Eeden

    18 Oct 12 at 7:51 am

Leave a Reply