0

I am making a shell script that automatically create users, but I cannot think of how to use passwd command within my shell script, how should I use it with shell script? --stdin option doesn't work for me

manatails008
  • 229
  • 4
  • 8

3 Answers3

1

Try expect(1).

Carl Norum
  • 219,201
  • 40
  • 422
  • 469
1

Some implementations of passwd have the --stdin flag which you can use like so:

passwd --stdin user <<<"SoMePasSw0rd"
SiegeX
  • 135,741
  • 24
  • 144
  • 154
0

Works for me on Debian

echo -e "$NEWPASS\n$NEWPASS" | passwd $USER
54R1N
  • 1