CommandShell(3) User Contributed Perl Documentation CommandShell(3)NAMENOCpulse::CommandShell - an abstract definition of a command shell
interface
SYNOPSIS
package NOCpulse::SSHRemoteCommandShell;
use NOCpulse::CommandShell;
@ISA=qw(NOCpulse::CommandShell);
sub overview {
return "This component give shell based probes access to a command shell via an SSH connection"
}
sub registerSwitches
{
my $self = shift();
$self->SUPER::registerSwitches;
$self->addSwitch('sshuser','=s','1','nobody','Name of the user to log in as');
$self->addSwitch('sshhost','=s','1','localhost','Host to log into');
}
sub initialize
{
my $self = shift();
$self->SUPER::initialize(shift());
if ($self->switchesAreValid) {
$user = $self->switchValue('sshuser');
$host= $self->switchValue('sshhost');
$self->set_shellCommand('/usr/bin/ssh');
$self->set_shellSwitches('-l', $user,
'-p','4545',
'-i','%/var/lib/nocpulse/.ssh/nocpulse-identity',
'-o','BatchMode=yes',
$host,
'/bin/sh -s');
}
return $self;
}
DESCRIPTIONNOCpulse::CommandShell is a subclass of CommandLineApplicationComponent
that defines a framework for describing access to a command shell. By
itself it knows nothing - you must subclass it for it to be useful
(examples include NOCpulse::LocalCommandShell and
NOCpulse::SSHRemoteCommandShell).
REQUIRES
Perl 5.004, CommandLineApplicationComponent, IPC::Open3
INSTANCE METHODSinstVarDefinitions()
Defines the following:
shellCommand - the program that gets executed in order to obtain
the shell
shellSwitches - switches to the shell command
probeCommands - the command(s) that the user of the Command Shell
wants to run
probeSwitches - (deprecated)
stdout - contains the stdout of the probeCommands after execution
stderr - contains the stderr of the probeCommands after execution
exit - the exit level of the probeCommands after execution
initialize()execute()
Executes probeCommands by passing them into the stdin of
shellCommand (where shellCommand is executed with shellSwitches).
It captures all stdout and stderr to their corresponding instance
variables, and sets the exit instance variable to the exit status
of probeCommands.
Both stdout and stderr will contain one string with zero or more
newlines.
set_shellSwitches(<@switchList>)
Sets shellSwitches to the array of switches passed in. (Overrides
normal Object set_xxx behavior)
set_probeSwitches(<@switchList>)
deprecated - don't use
get_shellSwitches()
Returns the shellSwitches array of switches. (Overrides normal
Object set_xxx behavior)
get_probeSwitches()
deprecated - don't use
perl v5.14.0 2009-02-19 CommandShell(3)