Linux SCP Expect Script


usage: expect_scp.exp myfile.7z
file: expect_scp.exp
#!/usr/bin/expect -f
set filename [lindex $argv 0]
set timeout -1
spawn scp $filename myusername@192.168.1.123:/home/myusername/
set pass "mypassword"
expect {
        password: {send "$pass\r" ; exp_continue}
        eof exit
}
192.168.1.123 - change to the ip address of destination server
myusername - change to user account of destination server
mypassword - change to password of user account of destination server
code snippets are licensed under Creative Commons CC-By-SA 3.0 (unless otherwise specified)

lois garcia on 2010-07-30 00:13:59
THANK YOU! Exactly what I needed. Now, to add an array...

Nanaz Nozar on 2013-03-12 10:27:17
this sample in very useful for me. (set timeout -1) help me too much. thanks a lot...

Trace on 2013-03-12 17:57:32
Genial, funciona muy bien.

Gracias

vposhan on 2016-05-12 06:29:27
My search ends here. you saved my day. Thank you and God Bless you.