I am trying to write a very simple shell script in Linux. The Scenario I am trying to achieve is:
Creating an user account and giving it a password internally (No inter
When using HEREDOC notation, you must write the closing word (EOF
in your case) in a line by itself, without any leading or trailing whitespace.
But in this case I would use another approach:
You can use chpasswd
. This command is shipped in all linux distros (that I know of) and I think in UNIX variants too.
The usage is pretty simple, you just pass via the STDIN a username:password
combination and that's all, one combo per line. To change the password for a single user, just do a simple echo:
echo "demo:myPasswd" | chpasswd