expect处理htpasswd交互

网友投稿 526 2022-09-22

expect处理htpasswd交互

expect处理htpasswd交互

vim expect_test.sh

#!/usr/bin/expect

set htpasswdpath [lindex $argv 0]

set username [lindex $argv 1]

set userpass [lindex $argv 2]

# spawn the htpasswd command process

spawn htpasswd -c $htpasswdpath $username

# Automate the 'New password' Procedure

expect "New password:"

send "$userpass\r"

expect "Re-type new password:"

send "$userpass\r"

expect eof

chmod +x expect_test.sh

./expect_test.sh /usr/local/nagios/etc/htpasswd.users(这个是$argv 0) nagiosadmin(这个是$argv 1) 123.com(这个是$argv 2)

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:100 道 Linux 笔试题,能拿 80 分就算大神!(100寸电视长宽多少)
下一篇:AIX 常用命令汇总
相关文章

 发表评论

暂时没有评论,来抢沙发吧~