参数不适用于通过命令行期望

参数不适用于通过命令行期望

在这里,我创建了执行脚本ansible-playbook,在执行脚本询问Sudo password我必须发送哪一个之后(须藤密码)虽然expectsend出现以下错误:

脚本 :

$ cat changedns

#!/usr/bin/expect -f
spawn ansible-playbook -i "$1," /home/admin/ansible/test.yml -K 
match_max 100000
expect "SUDO password:"
send -- "admin@123\r"
send -- "\r"
expect eof

输出:

$ ./changedns bn
can't read "1": no such variable
    while executing
"spawn ansible-playbook -i "$1," /home/adminto/ansible/test.yml -K "
    (file "./changedns" line 2)

有人知道如何处理这个问题吗?

相关内容