mmdbcn 发表于 2018-9-1 08:08:04

perl 批量更改密码

  #/usr/bin/perl
  use 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]
查看完整版本: perl 批量更改密码