Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Change a Unix/Linux password

Status
Not open for further replies.

PalOwl

Programmer
Oct 30, 2001
6
0
0
GB
Does anyone of a way to change a linux password WITHOUT needing the Expect module or any modules (this is because of hosting restrictions) as below. It require multiple lines which I cant seem to do.

Thanks in advance

sub changePasswds {
print &quot;<BR>Change Password<BR><BR>&quot;;
my($userid) = $form{'alias'};
my($newpass) = $form{'password'};

# Change Linux passwd...
$command = Expect->spawn(&quot;/usr/bin/passwd $userid&quot;) or die &quot;Couldn't start program: $!\n&quot;;
$command->log_stdout(0);
unless ($command->expect(5, &quot;New password: &quot;)) {};
print $command &quot;$newpass\r&quot;;
unless ($command->expect(5, &quot;Re-enter new password: &quot;)) {};
print $command &quot;$newpass\r&quot;;
$command->soft_close();

# OK, we're done...
print &quot;\n\n Complete: password changed for $userid: $newpass\n\n&quot;;

}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top