perl 批量更改密码

#/usr/bin/perl
use strict;
use Expect;
open(PASSWD,"1") or  die print "cann't open 1:$!\n";
while(<PASSWD>){
chomp;
my $name=$_;
my $exp=new Expect;
my $command="vpasswd $name";
$exp->spawn($command) or die "cannot spawn $command: $!\n";
my $passwd=$exp->expect(1,"Please");
$exp->send("123456\r\n") if ($passwd);
my $retry=$exp->expect(1,"enter password again");
$exp->send("123456\r\n") if ($retry);
$exp->interact();
}

你可能感兴趣的:(职场,perl,休闲)