I am still trying to understand how to put system and have header in the right place. Ideally what I am trying to achieve is this :
============hostname01============ bla bla bla ============hostname02============ bla bla bla ============hostname03============ bla bla bla
#!/usr/bin/perl -w use warnings; use strict; use Expect; my $filename = "/var/tmp/expect_script.log"; my $header = "\n\n======= system =======\n"; my $timeout = 60; my @servers = qw( hostname01 hostname02 hostname03 hostname04 ); for my $server (@servers) { # do your thing with $server change_password($server); } sub change_password { my $system = shift; my $ssh = Expect->new('ssh amagana@' . $system); $ssh->log_file("$filename"); $ssh->debug(1); $ssh->print_log_file($header); $ssh->expect ( $timeout, [ qr/Password:/], [ qr/Are you sure you want to continue connecting \(yes\/no\)?/] );
In reply to Re^10: expect.pm header
by amagana
in thread expect.pm header
by amagana
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |