perl 批量更改密码
#/usr/bin/perluse strict;
use Expect;
open(PASSWD,"1") ordie print "cann't open 1:$!\n";
while(){
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();
}
页:
[1]