linux下不用expect一行修改密码

来源:互联网 发布:php artisan clear 编辑:程序博客网 时间:2024/06/01 20:11
前些时间有个小项目需要用shell编写一些小程序,其中需要编写一个让用户修改密码的东东,
用户需求就是这么BT,系统自带的passwd多好啊,没办法只得写了,由于不想装expect(实际上懒得装)。
flw大侠提示passwd有个--stdin的东东,于是。。。。
当时问了不少人,都说不知道怎么办。
[root@fly root]# echo 222222|passwd --stdin root
Changing password for user root.
passwd: all authentication tokens updated successfully.
 
原创粉丝点击