spawn, expect, send aborts during scp transmission

0

I have a basic scp sending mechanism with spawn, expect and send.

However it gets aborted during the scp transmission.

Here is the expect command:

expect -c "spawn sh -c {scp -r -P 22 /tmp/rootfs/* root@IP:/.}
expect {
password: {send \"pw12\r\"; exp_continue }
}
exit"

This gets interrupted during the scp transmission.

However if I try like this:

scp -r -P 22 /tmp/rootfs/* root@IP:/.

It will ask for the password, then I type it in, and all the files gets uploaded.

I could not dig deeper yet, what could be the problem?

Daniel

Posted 2019-10-28T21:54:49.203

Reputation: 139

2This maybe? – Kamil Maciorowski – 2019-10-28T22:44:42.533

Answers

1

As @Kamil comments, consider the timeout -- how long does it take to transfer those files?

Also, expect to see the end of the spawned process:

expect {
    password: {send \"pw12\r\"; exp_continue }
    eof
}

glenn jackman

Posted 2019-10-28T21:54:49.203

Reputation: 18 546