I have attached the modified script beacuse the original script is for changing the password across multiple servers and i guess this is not what you require.
You need to execute the script from root user. It will create a log file in the directory from which you are executing the script.
You can change the password for root and a user but you can do a small modification and the script will change the password for root and any user.
Amit
Hello Amit,
I am trying to get a perl script to communicate with the passwd program. I do not have access to the modules expect or IO:

ty. I also do not have access to the expect utility.
So far I have found a free pty/tty pair and opened them and set them to autoflush. Then I fork.
In the child I close stdin, stdout and stderr to reopen them associated to the new tty handle and exec passwd.
In the parent I want to read and write to the pty to interact with passwd. This is not working. The passwd direct access to the tty is not reaching my tty.
Maybe I need to set the controling tty in the child before doing the exec? How do I do that?
Cheers,
sut