was able to make it work but not sure if I am doing the right thing.
use warnings;
use strict;
use Expect;
my $exp = new Expect;
my $password = 'abc123';
my $user = 'userX';
my $host = '10.3.3.1';
# typical regex pattern for end of /bin/sh prompt:
my $shell_prompt = qr/[\$\#]\s*$/;
my $login =
"/usr/bin/ssh [EMAIL PROTECTED]";
$exp->spawn($login)
or die
"Can't login to $host as $user: $!\n";
## Enables internal debugging
#$exp->exp_internal( 1 );
$exp->log_file("./log_this.txt");
$exp->expect(5, '-re', '(RSA)');
my @matchlist = $exp->matchlist;
$exp->send("yes\n")
if ( ( $exp->matchlist)[0] );
$exp->expect(5, "password: ");
$exp->send("$password\n");
$exp->expect(2, -re => $shell_prompt);
$exp->send("cat /tmp/file1\n");
my @result = $exp->expect(5, -re => $shell_prompt);
my $ltedge_now = $result[1];
print "\n\n\n $ltedge_now\n";
$exp->send("exit\n");
$exp->soft_close();
$exp->log_file(undef);
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/