gsh - Global Shell run commands in parallel to multiple machines



 SYSTEMS is a combination of ghost macros.  See ghosts(1).
 CMD is the command to run
 -h, --help            Display full help
 -d, --debug           Turn on exeuction debugging reports
 -h, --no-host-prefix  Does not prefix output lines with the host name
 -s, --show-commands   Displays the command before the output report
 -n, --open-stdin      Leaves stdin open when running (scary!)
 -l, --user USER       SSH's to the host as user USER
 -r, --run-locally     Run commands locally (replaces $host with host)
 -o, --self-remote     Run locally instead of over SSH for local host
 -V, --version         Report the version and exit


The idea behind this tool originally came from wanting to do something on each machine in our network. Existing scripts would serially go to each machine run the command, wait for it to finish, and continue to the next machine. There was no reason why this couldn't be done in parallel. The problems, however, were many. First of all, the output from finishing parallel jobs needs to be buffered in such a way that different machines wouldn't output their results on top of eachother. A final bit was added because it was nice to have output alphabetical rather than first-done, first-seen. The result is a parallel job spawner that displays output from the machines alphabetically, as soon as it is available. If ``alpha'' take longer than ``zebra'', there will be no output past ``alpha'' until it is finished. As soon as ``alpha'' is finished, though, everyone's output is printed.

Sending a SIGUSR1 to gsh(1) will cause it to report which machines are still pending. (Effectively turns on --debug for one cycle.)


-h, --help
Displays this help.

-d, --debug
Turns on debugging. A regular report of pending hosts is create, and PIDs are show as commands are executed and reaped.

-h, --no-host-prefix
Turns off the prefixing of hostnames to the output reports.

-s, --show-command
Displays the command being run before the output report for each host.

-n, --open-stdin
Leave stdin open when SSH'ing. This can cause hangs and other strange situations, but can be useful in uncommon situations where you need to pipe input to all of the child processes.

-l, --user USER
SSH as a user USER on the remote machines.

-r, --run-locally
Instead of SSH'ing to hosts, run the commands locally. The string '$host' will be replaced with the name of the current host. For example:
  gsh -r all 'echo $host'

-o, --self-remote
Normally, if the local host running gsh is listed among the hosts to SSH to, gsh will just run the command locally instead of attempting to SSH back to the local machine. If you want gsh to SSH to the local machine anyway, turn this option on.

-V, --version
Displays the version information and exits.


POSIX File::Temp SystemManagement::Ghosts


I bet.


perl(1), ghosts(1), ssh(1), SystemManagement::Ghosts(1)


Kees Cook <>|


Copyright (C) 1998-2006 Kees Cook <>

Supposedly based on original code distributed with Perl Distribution.

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.


Revision: $Revision $