Linux间文件复制
2018-10-12 本文已影响19人
Steven_cao
#!/bin/expect
# Author:Steven
# Desp: cp file from one linux to another linux
# src_file 拷贝文件的文件全路径
# target_linux_username 目标机子的用户名
# target_linux_password 目标机子的密码
# target_path 文件要拷贝到目标机子的路径
src_file=srcFile
target_linux_username=username
target_host=host
target_linux_password=password
target_path=path
spawn scp $src_file $target_linux_username@$target_host:$target_path
expect {
"*(yes/no)?" {send "yes\r";exp_continue}
"password:" {send "$target_linux_password\r"}
}
expect "100%"