provide a user password from a script

Hi all,
passwd <username> < /var/adm/passwd.txt

cat /var/adm/passwd.txt
abcd1234
abcd1234

when I run this from the script, it comes with:
New password:

It is not able to pick from the location /var/adm/passwd.txt.
thanks in advance.

there is a utility called Expect that can do that for you.

this would help you to get started

Do I need to install expect as an add-on?? I do not think it is already there in my box.

thanks

Only if you want to use it

Padow,
Is "expect" the only way around to get this done. There has to be another way other than expect. Only my guess though..I can afford to put expect on one of the box to get it done but this has to be rolled out on number of servers and I do not think I will be able to have "expect" in all other servers.

The best way is just to manually type the password in at the password prompt, rather than putting a password in a script anyway.

I wouldn't recommend it unless you are very sure you know what you are doing, but you could write a script to edit /etc/shadow or /etc/security/password depending on your OS and insert the password hash into the correct field.