my $expPty = 1; # pty mode my $expDebug = 3; # Expect debug level $sshUX = Expect->new; # create Expect object $sshUX->debug($expDebug); # debugging $sshUX->log_file($expUXLogFile, "w"); $sshUX->raw_pty($expPty); $sshUX->expect(10, [qr /password: $/ => # got password prompt sub { my $self = shift; $self->send("$passw\r"); print "Sent password!\n";#debug exp_continue; } # end sub ], [qr /session:\n$/ => # got reason prompt sub { my $self = shift; $self->send("Get configs\r"); print "Sent session reason!\n";#debug exp_continue; } # end sub ], # Timeout trap [timeout => sub { $expUXStatus = 1; print PL "Error,Timeout while waiting $expTimeOut secs for login on [$UXHost] user[$usr]. Error:" . $sshUX->exp_error() . "\n"; } ], # EOF trap [eof => sub { $expUXStatus = 2; print PL "Error,Premature EOF during login for [$UXHost] user[$usr]. Error:" . $sshUX->exp_error() . "\n"; } ], '-re', qr /%$/, # wait for device prompt '%' ); # End expect for Login processing print "Finished processing login expect expUXstatus[$expUXStatus]\n"; # debug