如何一行这个“期望”的命令?

我想单线这一点

#!/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'