
06-09-2008, 05:06 PM
|
|
Member
User
|
|
Join Date: Oct 2007
My distro: Linux RHEL 5
Posts: 33
Rep Power: 0
|
|
Quote:
Originally Posted by monk
Use the Unix::PasswdFile module (cpan module), it provides an abstract interface to /etc/passwd format files. It automatically handles file locking, getting colons in the right places, and all the other niggling details.
Code to change password for monk user:
Code:
#!/usr/bin/perl
use Unix::PasswdFile;
$pw = new Unix::PasswdFile "/etc/passwd";
$pw->passwd("monk", $pw->encpass("My-New-Password"));
$pw->commit();
undef $pw;
function passwd( USERNAME [,PASSWD] )
It can read or modify a user's password. Returns the encrypted password in either case. If you have a plaintext password, use the encpass method to encrypt it before passing it to this method. Refer to man page for more details
|
Hi Monk,
Can you pls tell me how to run this script. I am completely nuts abt perl.
THanks,
VIKAS
|