perl 批量更改密码
时间:2010-09-29 来源:jiaminqiang
#/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();
}
相关阅读 更多 +
排行榜 更多 +