Changing an AIX password via script?
Use GNU passwd
stdin flag.
From the man
page:
--stdin This option is used to indicate that passwd should read the new password from standard input, which can be a pipe.
NOTE: Only for root user.
Example
$ adduser foo $ echo "NewPass" |passwd foo --stdinChanging password for user foo.passwd: all authentication tokens updated successfully.
Alternatively you can use expect
, this simple code will do the trick:
#!/usr/bin/expectspawn passwd fooexpect "password:"send "Xcv15kl\r"expect "Retype new password:"send "Xcv15kl\r"interact
Results
$ ./passwd.xp spawn passwd fooChanging password for user foo.New password: Retype new password: passwd: all authentication tokens updated successfully.