SteveS832001 has asked for the wisdom of the Perl Monks concerning the following question:
#!/usr/bin/perl -w use Expect; use strict; #list of Global Variables my $password = "password"; my $timeout = 10; #Array for server list my @ServerList; #Server list import my $ServerListFile = "serverlist.txt"; open my $handle, '<', $ServerListFile or die "Error: Unable to open fi +le for processing."; chomp(@ServerList = <$handle>); close $handle or die "Error: Unable to close file for Server Import."; #End Server list import foreach (@ServerList) { my $spawn = expect->spawn("ssh $_") or die "Couldn't open ssh session to $_, $!\n"; my $ret = $spawn->expect($timeout, [qr/Password:/ => sub { $spawn->send("$password\n"); +exp_continue; } ], [qr/3par/ => sub { $spawn->send("showsys\n"); } +], ); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Expect.pm Help with Automating SSH
by hippo (Archbishop) on Apr 14, 2016 at 08:36 UTC | |
|
Re: Expect.pm Help with Automating SSH
by cavac (Prior) on Apr 14, 2016 at 06:20 UTC |