> What
Clsh is a shell intended to run commands on groups of machines.
Clsh has its own commands and does more than executing standard commands on multiple machines.

> How
Clsh is a simple perl script with internal commands for its environment configuration.
Clsh uses OpenSSH for remote command execution.
Commands are defined in modules.
Clsh has an interactive mode.

> Examples
command
clsh@desktop:~$ clsh viewhosts
clsh> waiting for results ...
clsh> output from master
  no records
clsh> output from desktop
  192.168.1.46    master
  192.168.1.43    desktop
clsh@desktop:~$
internal command
clsh@desktop:~$ clsh commands
clsh> internal commands :
commands
clsh> commands :
help
test
viewhosts
clsh@desktop:~$
interactive
clsh@desktop:~$ ./clsh

clsh> viewhosts
clsh> waiting for results ...
clsh> output from master
  no records
clsh> output from desktop
  192.168.1.46    master
  192.168.1.43    desktop
clsh> done.
clsh> commands
clsh> internal commands :
commands
clsh> commands :
help
test
viewhosts
clsh> done.
clsh> die
clsh> quitting.
clsh@desktop:~$
> Commands
A command is defined by a
Clsh::Command::<CommandName>.pm
module which contains the command to execute.
and an optional
Clsh::Output::<CommandName>.pm
module to handle output.
> Targets
A target is defined by
a name            # we are DNS independent
an ip address     # used by ssh
an os string      # if we have different commands
a list of groups  # used for target selection
Targets are stored in a text file
conf/Targets.conf
and can thus be edited by hand or with the commands
addtarget
deltarget
You can list all targets with the command
targets
or the list returned for a given parameter
targets parameter
> Extensible
To add a command you need to create a Command module
Clsh::Command::<newcommand>.pm
example
 1  # Command package for Clsh command viewhosts
 2  package Clsh::Command::viewhosts;
 3
 4  use strict;
 5  use warnings;
 6
 7  sub get_command {
 8
 9    my $object  = shift;
10    my @options = shift;
11
12    if (( $options[0] ) and ( $options[0] eq 'help' )) {
13      print qq~clsh> help
14    desc    : list ipv4 entries found in hosts files
15    syntax  : clsh viewhosts
16  ~;
17      return 1;
18    }
19    else {
20      my $COMMAND = 'cat /etc/hosts';
21      return $COMMAND;
22    }
23  }
24
25  1;
26  # END
    In this example, what you have to edit is
 1  # Command package for Clsh command viewhosts
 2  package Clsh::Command::viewhosts;

13      print qq~clsh> help
14    desc    : list ipv4 entries found in hosts files
15    syntax  : clsh viewhosts

20      my $COMMAND = 'cat /etc/hosts';
And an optional Output module if you want to filter the output from the command.
Clsh::Output::<newcommand>.pm
example
 1  # Output package for Clsh command viewhosts
 2  package Clsh::Output::viewhosts;
 3
 4  use Regexp::Common qw/net/;
 5
 6  sub handle_output {
 7
 8    my $item = shift;
 9    my $output = shift;
10
11    my $cnt    = 0;
12    foreach ( @$output ) {
13      if ( /$RE{net}{IPv4}/ ) {
14        print "  $_";
15        $cnt++;
16      }
17      print "$_" if ( /^output/ );
18    }
19    print "  no records\n" if ( $cnt == 0 );
20    return 0;
21  }
22
23  1;
24  # END
> Download
first release on 1 february 2010.
> Contact
clsh@at-info.ch