View Single Post

  #2 (permalink)  
Old 01-01-2006, 02:50 AM
nixcraft's Avatar
nixcraft nixcraft is offline
Never say die
User
 
Join Date: Jan 2005
Location: BIOS
My distro: Ubuntu
Posts: 1,061
Rep Power: 10
nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute
Default

You really don't need a perl script. All you need is following shell script and expect tool:
Code:
vi npasswd
Add following lines to it:
Code:
#!/bin/sh
# \
exec expect -f "$0" ${1+"$@"}
set password [lindex $argv 1]
spawn passwd [lindex $argv 0]
expect "assword:"
send "$password\r"
expect "assword:"
send "$password\r"
expect eof
To change password for user vivek:
Code:
npasswd vivek 123456
Where,
npasswd : script name
vivek : username
123456: Newpassword

Script must be run as a root user, it can be call from perl, php or any other lanauge. Download expect tool here: http://expect.nist.gov/
__________________
Vivek | My personal blog
Linux Evangelist
Play hard stay cool
Reply With Quote