expect实现远程copy

2019-05-05  本文已影响0人  词画人间

#!/usr/bin/expect

set timeout 10

set host "IP地址"

set username "username"

set password "password"

set path "需要拷贝的文件路径"

set pathlocal "本地文件路径"

spawn scp $username@$host:$path $pathlocal

expect {

"(yes/no)?"

{

send "yes\n"

expect "*password:" { send "$password\n"}

}

"*password:"

{

send "$password\n"

}

}

expect "100%"

expect eof

上一篇 下一篇

猜你喜欢

热点阅读