in reply to Re^17: expect.pm header
in thread expect.pm header
Do I place the code you recommended inside sub change_password ?
Currently I am getting this error now
perl tester-a.pl Global symbol "$system" requires explicit package name at tester-a.pl +line 27. Global symbol "$ssh" requires explicit package name at tester-a.pl lin +e 28. Global symbol "$system" requires explicit package name at tester-a.pl +line 30. Execution of tester-a.pl aborted due to compilation errors.
#!/usr/bin/perl -w use warnings; use strict; use Expect; my $filename = "/var/tmp/expect_script.log"; my $header = "\r\n\r\n======= system =======\r\n"; my $timeout = 60; my @servers = qw( remotehost ); for my $server (@servers) { # do your thing with $server change_password($server); } sub change_password { my $my_header = $header; $my_header =~ s/system/$system/; $ssh->print_log_file($header); my $ssh = Expect->new('ssh amagana@' . $system); $ssh->debug(1); $ssh->log_file("$filename"); $ssh->expect ( $timeout, [ qr/Password:/], [ qr/Are you sure you want to continue connecting \(yes\/no\)?/] );
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^19: expect.pm header
by sn1987a (Deacon) on Apr 09, 2015 at 03:25 UTC | |
by amagana (Acolyte) on Apr 10, 2015 at 15:07 UTC | |
by sn1987a (Deacon) on Apr 10, 2015 at 15:39 UTC | |
by amagana (Acolyte) on Apr 10, 2015 at 19:14 UTC |
In Section
Seekers of Perl Wisdom