I'm trying to change a local user password (UID:500) as root but it doesn't change the password. Here's the script
Code:
#!/usr/bin/perl
use Expect;
# my $user = shift;
# my $password = shift;
my $user = "me";
my $password = "443rfgt";
print "Running 'passwd ${user}'\n";
my $exp = Expect->spawn("passwd ${user}") or die "Can't run 'passwd ${user}'\n";
$exp->expect(500,
[qr'New UNIX password: $',
sub {
my $fh = shift;
$fh->send("${password}\n");
print "sent '${password}'\n";
exp_continue;
}
],
[qr'Retype new UNIX password: $',
sub {
my $fh = shift;
$fh->send("${password}\n");
print "sent '${password}'\n";
}
]);
Here's the output -
Quote:
Running 'passwd me'
Changing password for user me.
New UNIX password: sent '443rfgt'
Retype new UNIX password: sent '443rfgt'
|