App-MrShell

 view release on metacpan or  search on metacpan

mrsh  view on Meta::CPAN

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
C<-l> will only appear in the argument list when C<%u> has a value.  If an
arguemnt of the form C<[]%u> (C<[%u]%u> works identically), it will only appear
in the argument list when C<%u> has a value.

The following command is expanded as follows for C<jettero@corky> and C<corky>
respectively.

    ssh [%u]-l []%u %h
    ssh -l jettero corky # for jettero@corky
    ssh corky            # for corky

=back

=head1 CONFIG FILE

The config file is loaded using the L<Config::Tiny> module, which supports
basic "standard" C<.ini> files.  L<mrsh> reads two sections for values and
ignores all values it doesn't understand.

=head2 B<[options]>

=over

=item B<default-hosts>

When no hosts are specified for a command, L<mrsh> will seek to use these hosts
and L</[groups]> instead.

=item B<shell-command>

This is the above B<-s> setting, which allows changing the shell command.

=item B<no-command-escapes>

This is the above B<-N> setting, which disables escaping of arguments during
host-routing mode.

=back

=head2 B<[groups]>

The B<[groups]> section can contain as many hostname values as ... your platform
as memory.  Groups are expanded by pre-fixing with an C<@> character when passing
hostnames to B<-H> or via the C<default-hosts> option above.

Hosts and host routes are space separated.

If a group contains references to other groups, it will automatically be



( run in 0.437 second using v1.01-cache-2.11-cpan-d7a12ab2c7f )