Hi,
 
this is my script:
 
#!/usr/bin/perl -w
 
use Expect;
 
$passwdex = "/usr/bin/passwd";     # umiestnenie programu passwd
 
sub ChangeUnixPasswd {
      my ($account,$passwd) = @_;
 
      my $pobj = Expect->spawn($passwdex, $account);
      die "Unable to spawn $passwdex:$!\n" unless (defined $pobj);
 
      $pobj->log_stdout(0);
 
      $pobj->expect(10,"New password:");
      print $pobj "$passwd\r";
      $pobj->expect(10,"Retype new password:");
      print $pobj "$passwd\r";
 
      $result = (defined ($pobj->expect(10,"passwd: updating the
database...")) ?
                                  "" : "passwd: Permission denied");
 
      $pobj->soft_close(  );
 
      return $result;
}
 
$acc = "user";
$password = "newpassword";
 
unless ($result = &ChangeUnixPasswd("user",$password)) {
      print "suceed: $acc $password\n";
} else {
      print "failed.\n";
}
 
exit;
 
This works, but if I need to call 
unless ($result = &ChangeUnixPasswd($acc,$password)) {
 
i get error like this:
print on closed filehandle Symbol::GEN0 at .
 
Please help!
 
Thank you, Pavel


Reply via email to