我想单行本
#!/usr/bin/expect
spawn ssh-copy-id -i .ssh/id_dsa.pub root@testip
expect "Are you sure you want to continue connecting (yes/no)?"
send -- "yes\r"
expect eof
我认为应该是
/usr/bin/expect -c 'expect "\n" { eval spawn ssh-copy-id -i .ssh/id_dsa.pub root@testip; expect "Are you sure you want to continue connecting (yes/no)?"; send -- "yes\r" }'
但事实并非如此。
谁能看出它应该如何?
最佳答案
也许你不再需要它了,但它应该是这样的:
/usr/bin/expect -c 'spawn ssh-copy-id -i .ssh/id_dsa.pub root@testip ; expect "Are you sure you want to continue connecting (yes/no)?" ; send -- "yes\r" ; expect eof'
关于linux - 如何单行执行此 "expect"命令?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12215596/