sub new { my $class = shift; my $self = {}; bless $self, $class; my $log = Log::Log4perl->get_logger("$class"); $self->{LOGGER} = $log; my $pty = $self->spawn("/bin/bash"); # spawn() defined below $self->{PTY} = $pty; my $exp = Expect->exp_init($pty); my $ref = $exp->expect(TIMEOUT, [ $shell_prompts ] ); if (!$ref){ $log->warn("Timeout received!"); return -1; } $exp->clear_accum(); #$exp->log_stdout(1); $exp->raw_pty(1); #$exp->debug(3); $Expect::Multiline_Matching = 0 ; $self->{EXPECT} = $exp; $log->debug("Creating instance $class"); return $self; }