In shell script set the new password for a user

A

AJAY SHARMA

Guest
In shell script i want set the password for user itk .. Below is the scenario.

The script has to wait for New UNIX password: and then enter new password and then again wait for

Retype new UNIX password: and then enter the same password again and then wait for successfully message and then move ahead with other commands in the script.

root@ESELIVEDOSDP013 /var/opt # passwd itk
Changing password for user itk.
New UNIX password:
BAD PASSWORD: it is based on a dictionary word
Retype new UNIX password:
passwd: all authentication tokens updated successfully.
 


How about just "passwd $USER && <subsequent commands>". According to the manpage, passwd only exits with success if no error was encountered in the process, and "&&" will not run subsequent commands unless passwd is successful.
 

Members online


Latest posts

Top