Linuxシェルはpasswdの相互作用を処理することを期待します

例は次のとおりです。

#!/usr/bin/expect

set username [lindex $argv 0]
set userpass [lindex $argv 1]

# spawn the htpasswd command process
spawn passwd $username

# Automate the 'New password' Procedure
expect "New password:"
send "$userpass\r"

expect "Retype*"
send "$userpass\r"
expect eof

chmod +x scriptname
./scriptname username password

 

 

おすすめ

転載: blog.csdn.net/whatday/article/details/113860519