Sandra Schlichting
Sandra Schlichting

Reputation: 26026

How to one-line this "expect" command?

I would like to one-line this

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

which I would assume should be

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

but it is not.

Can anyone see how it should be?

Upvotes: 3

Views: 3625

Answers (1)

enrico.bacis
enrico.bacis

Reputation: 31524

Maybe you will not need it anymore, but it should be like this:

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

Upvotes: 5

Related Questions