App-MrShell
view release on metacpan or search on metacpan
# list /tmp on all the hosts in @gr1
mrsh @gr1 -- ls -al /tmp
# list /tmp on all the hosts in @gr1 with a logfile
mrsh --log logfile @gr1 -- ls -al /tmp
=over
=item B<-->
Sometimes the option processor get confused by switches and options for the
command being sent to the remote hosts. B<--> tells the options parser to quit
looking.
=item B<--groups> B<-g> B<--list>
List the groups and their hosts and exit. Will use groups listed in B<-H>
switches if applicable (ignoring B<-H> arguments that are not groups).
=item B<--host> B<-H>
Names of hosts or L</[groups]> upon which to run commands. Groups are prefixed
with an C<@> character and can only be specified in the configuration file (see
L</CONFIG FILE>).
Host and group specifications that overlap are reduced to a unique set, so if
C<@localhosts> contains C<host1> and C<@desktops> contains C<host1>, and for
whatever reason C<-H host1> is also specified on the command line ... C<host1>
will only appear in the hosts list just the one time.
Hostnames may be subtracted from any lists provided (via groups or B<-H>) by
prefixing the hostname (but not group) with C<->.
For instance, if C<@hosts> contains a host named C<host1>> and C<host1>> is
unavailable, users might type something like this:
mrsh @hosts -H-host1 uptime
=item B<--conf> B<-c>
By default, L<mrsh> will look for C<.mrshrc> the user's home directory. Users
may change the location with this switch. The switch takes an optoinal
argument, the location. When a location is not specified, it disables the
loading of any config files.
Caveat: careful that -c doesn't slurp up the next word on the command line. It
wants to eat your arguments.
=item B<--log> B<-l> B<--trunc> B<-t>
L<mrsh> doesn't keep any logs by default. Users may specify a logfile location
to start logging. Logs will be appended (even between runs) unless the truncate
option is specified -- in which case, the logfile will simply be overwritten
instead.
=item B<--shell> B<-s>
By default, L<mrsh> uses the following command as the shell command.
ssh -o BatchMode yes -o StrictHostKeyChecking no -o ConnectTimeout 20 [%u]-l []%u %h
The C<%h> will be replaced by the hostname(s) during execution
(see L</COMMAND ESCAPES>).
Almost any shell command will work, see C<t/05_touch_things.t> in the
distribution for using perl as a "shell" to touch files. Arguments to B<-s> are
space delimited but understand very simple quoting:
=item B<--noesc> B<-N>
During host routing mode, L<mrsh> will escape spaces and backslashes in a way
that openssh (L<http://openssh.com/>) will understand correctly. That behavior
can be completely disabled with this option.
=back
=head1 COMMAND ESCAPES
These things will be replaced before forking the commands on the remote hosts.
There aren't many of these yet, but there will likely be more in the future.
=over
=item B<%c>
The command number.
=item B<%h>
The hostname. The hostname escape supports a special host routing protocol.
Hostnames that contain the routing character will be expanded to magically
create sub-commands as needed to connect I<through> hosts while executing
commands.
When expanding a host route, all C<%h> will be replaced with the elements of
the command array up to that escape, plus the hostname, for each host in the
hosts route.
This expansion also optionally (see B<-N> above) expands spaces and slashes to
escaped values compatible with openssh (L<http://openssh.com/>).
This is perhaps more clear by example.
Let's say this is the command in question.
ssh -o 'BatchMode Yes' %h 'ls -ald /tmp/'
And let's say our hostname is C<corky!wisp>, then the command becomes:
ssh -o 'BatchMode Yes' corky ssh -o 'Batchmode\ Yes' wisp 'ls\\ -ald\\ /tmp'
=item B<%u>
Replaced with the username, if applicable. When hostname contains an C<@>
character, for example C<jettero@corky>, the portion before the C<@> is
considered a username.
=item conditional replacement
If an element in a command exists in the form C<[%u]-l>, then the argument
( run in 0.814 second using v1.01-cache-2.11-cpan-df04353d9ac )