开发者

passwd command in shell script

开发者 https://www.devze.com 2023-01-30 04:25 出处:网络
I am making a shell script that automatically create users, but 开发者_StackOverflow中文版I cannot think of how to use passwd command within my shell script, how should I use it with shell script? --s

I am making a shell script that automatically create users, but 开发者_StackOverflow中文版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


Try expect(1).


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

passwd --stdin user <<<"SoMePasSw0rd"


Works for me on Debian

echo -e "$NEWPASS\n$NEWPASS" | passwd $USER
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号