View Single Post

  #1 (permalink)  
Old 05-23-2007, 09:42 PM
james bond james bond is offline
Junior Member
User
 
Join Date: May 2007
My distro: Debian
Posts: 7
Rep Power: 0
james bond is on a distinguished road
Default let users change password using perl script?

Hi all,

I am following this thread by what its not working.
Quote:
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: Expect - Expect - Home Page
it works from command line but when put it in php page it doesn't. For that I followed this link.
Change Linux or UNIX system password using PHP script | nixCraft

But it doesn't work.
Reply With Quote