Linux – How do I execute this “expect” command in a single line?

How do I execute this “expect” command in a single line?… here is a solution to the problem.

How do I execute this “expect” command in a single line?

I want a single book

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

I think it 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 this is not the case.

Who can see how it should be?

Solution

Maybe you don’t 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'

Related Problems and Solutions