如何一行“预期”命令?

时间:2012-08-31 12:40:55

标签: linux bash

我想一行一行

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

但事实并非如此。

任何人都可以看到它应该如何吗?

1 个答案:

答案 0 :(得分:4)

也许你不再需要它,但它应该是这样的:

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