#!/usr/bin/perl use Expect; use Getopt::Long; my $exp = Expect->spawn("/usr/bin/ssh $username\@$ip") or die "Cannot spawn ssh: $!\n";; /* removed the ssh handling code */ $exp->send("show backup status\n"); $result=$exp->expect( $timeout, ['-re',qr'Backup file location:',sub {my $exp = shift; $exp->print_log_file($backup_Complete); $i=0; } ], ['-re',qr'>'] );