How-To‎ > ‎

Automate scp copy





Automate scp copy with password in script


copy.sh

#!/usr/bin/expect -f

# connect via scp
spawn scp derived/file.bin "root@1.2.3.4:/."
expect {
-re ".*es.*o.*" {
exp_send "mypassword\r"
exp_continue
}
-re ".*sword.*" {
exp_send "mypassword\r"
}
}
interact

Comments