linux shell expect 处理 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