App-MrShell

 view release on metacpan or  search on metacpan

lib/App/MrShell.pod  view on Meta::CPAN

executed.

=item B<set_debug_option>

Turn on various debugging messages.  The optional argument specifies the debug
level.  No argument, 0, and 1 are all equivalent.  While levels greater than one
indicate an increased amount of debugging noise.

=item B<set_no_command_escapes_option>

When expanding hosts in host-routing mode, slashes and spaces are escaped so
they function correctly when subshelled.  This disables that functionality.

=item B<read_config>

The options above can be specified from a L<config file|mrsh/CONFIG FILE>, which
is documented in the command line tool.  The config file is read using
L<Config::Tiny>.

=item B<set_usage_error>

lib/App/MrShell.pod  view on Meta::CPAN

=back

=head1 COMMAND METHODS

=over

=item B<set_hosts>

Set the hosts, groups, and routed strings for the next L</queue_command>.  Hosts
have some special magic concerning groups.  Hosts that being with an C<@>
character are considered groups are are expanded that way (see
L<config file|mrsh/[groups]>).

Also see the section on L<--host|mrsh/--host -H> in the L<mrsh> documentation.

=item B<queue_command>

Push a command into the stack for the given hosts (specified by L</set_hosts> or
by the default hosts in the L<config file|mrsh/CONFIG FILE>).

Commands are pushed as an array, although, given the nature of

mrsh  view on Meta::CPAN

        --shell   -s: change the (remote-)shell command
        --noesc   -N: do not escape the sub commands during host-routing mode
        --groups  -g: show groups and exit
        --list      : (nickname for --groups)
        --          : not strictly an option, but good to put before commands

=head1 DESCRIPTION

The B<-H> has some special magic concerning L</[groups]>.  If a group is
specified before any other options or options arguments arguments (but possibly
after other groups), it will automatically be expanded to have an imaginary
B<-H> before it.  Example:

    # 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

mrsh  view on Meta::CPAN


=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:

mrsh  view on Meta::CPAN

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

mrsh  view on Meta::CPAN

=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
recursively replaced.  This recursion naively assumes there are no loops, but
automatically stops about 30 deep.  If you get unexpected results, this could
be the problem.

=head2 EXAMPLE CONFIG



( run in 1.651 second using v1.01-cache-2.11-cpan-5b529ec07f3 )