Hi all, how do i get the complete string which has matched via regex when using Perl Expect.
#!/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'>'] );
Out put of the above command is :
How do we extract "location: /var/log/CPbackup/backups/x.x/x.x.x.x_01_1_Aug_2016_11_05.tgz" line from the output with perl expect ? Do note that i have tried to use $exp->match() but just displayes "Backup file location:" which is the regex=== local backup succeeded. Backup file location: /var/log/CPbackup/backups/x.x/x.x.x.x_01_1_Aug_2 +016_11_05.tgz Backup process finished in 00:48 seconds ===
In reply to Perl Expect : Get the complete matched string by cryptonite1
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |