From: MAGANA, A. S I C. U. A. 72 ABW/S. <and...@us...> - 2015-03-31 20:38:03
|
Thank you Matt, I just don't know how to put it in a working way I learn by examples I am a novice on perl and the modules. Respectfully, Andy #!/usr/bin/perl use strict; use Expect; # my @servers = qw( # server1.example.net # server2.example.net # server3.example.net # server4.example.net # server5.example.net # ); # # for my $server (@servers) { # # do your thing with $server # } my $filename = "/var/tmp/expect_script.log"; my $ssh = Expect->new('ssh amagana@remotehost'); $ssh->debug(1); $ssh->log_file($filename, 'w'); $ssh->expect(60, 'Password:'); $ssh->send("mycurrentpassword\n"); $ssh->expect(60, '$'); $ssh->send("su - root\n"); $ssh->expect(60, 'Password:'); $ssh->send("myrootpassword\n"); $ssh->expect(60, '#'); $ssh->send("passwd amagana\n"); $ssh->expect(60, 'New Password:'); $ssh->send("mynewpassword\n"); $ssh->expect(60, 'Re-enter new Password:'); $ssh->send("mynewpassword\n"); $ssh->expect(60, '#'); $ssh->send("exit\n"); $ssh->close(); //SIGNED// Andy Magaña UNIX Systems Administrator Diligent Contractor, 72nd Air Base Wing Tinker Air Force Base, Oklahoma Commercial: (405) 734-0341 -----Original Message----- From: Matt Zagrabelny [mailto:mzagrabe@d.umn.edu] Sent: Tuesday, March 31, 2015 3:25 PM To: MAGANA, ANDREAS S I CTR USAF AFMC 72 ABW/SCOOT Cc: ESRY JR., DON; exp...@li... Subject: Re: [Expectperl-discuss] expect.pm not updating password On Tue, Mar 31, 2015 at 3:16 PM, MAGANA, ANDREAS S I CTR USAF AFMC 72 ABW/SCOOT <and...@us...> wrote: > Hoooray! > Now I just need to know how to run this against a list of servers. This is pretty basic perl... my @servers = qw( server1.example.net server2.example.net server3.example.net server4.example.net server5.example.net ); for my $server (@servers) { # do your thing with $server } -m |