use TestRobot;
my $tr = TestRobot->new( 'config.yml' );
$tr->open;
my $s = $tr->exec('ls -l');
print $s;
#print "\n***\n";
#print unpack('H*', $/);
#print "\n***\n";
#print unpack('H*', 'abc');
#print "\n***\n";
#print unpack('H*', $s);
#print "\n***\n";
$tr->close;
####
sub exec {
my ( $self, $cmd ) = @_;
croak 'cannot exec unless state is open' unless $self->is_open;
croak 'need a command to execute' unless defined $cmd && $cmd ne '';
my $r = $self->{ssh}->exec( $cmd );
#my $q = chomp $r; print "$q gone\n";
# remove trailing prompt and surrounding whitespace from output
my $u = $self->{config}{test_server}{username};
$r =~ s/\[$u@.*$//g;
if ( wantarray ) {
my @a = split "\n", $r;
# chomp( @a );
return \@a;
} else {
return $r;
}
}
####
[00mtotal 24
drwxrwxr-x 2 testrobot testrobot 4096 Oct 11 12:33 [00;34mbin[00m
drwxrwxr-x 3 testrobot testrobot 4096 Oct 11 12:33 [00;34mtesting[00m
drwxrwxr-x 3 testrobot testrobot 4096 Oct 11 11:53 [00;34mwork[00m
[m]0;testrobot@svnsepia:~
***
0a
***
616263
***
1b5b30306d746f74616c2032340a64727778727778722d782020322074657374726f626f742074657374726f626f742034303936204f63742031312031323a3333201b5b30303b33346d62696e1b5b30306d0a64727778727778722d782020332074657374726f626f742074657374726f626f742034303936204f63742031312031323a3333201b5b30303b33346d74657374696e671b5b30306d0a64727778727778722d782020332074657374726f626f742074657374726f626f742034303936204f63742031312031313a3533201b5b30303b33346d776f726b1b5b30306d0a1b5b6d1b5d303b74657374726f626f744073766e73657069613a7e07
***