rsync 本地路径到挂盘路径 ;挂盘路径到本地
要解决的是每次都要输入密码,所以不能后台投递任务。
解决方案:
核心是expect
spawn
#!/usr/bin/expect -f
set timeout 10
set username [lindex $argv 0]
set password [lindex $argv 1]
set host [lindex $argv 2]
set src_file [lindex $argv 3]
set dest_file [lindex $argv 4]
spawn rsync -avtp $src_file $username@$host:$dest_file
expect {
"(yes/no)?"
{
send "yes\n"
expect "*assword" { send "$password\n"}
}
"*assword"
{
send "$password\n"
}
}
expect "100%"
expect eof
#!/usr/bin/expect -f
set timeout 10
set username [lindex $argv 0]
set password [lindex $argv 1]
set host [lindex $argv 2]
set src_file [lindex $argv 3]
set dest_file [lindex $argv 4]
spawn rsync -avtp  $username@$host:$src_file $dest_file
expect {
"(yes/no)?"
{
send "yes\n"
expect "*assword" { send "$password\n"}
}
"*assword"
{
send "$password\n"
}
}
expect "100%"
expect eof
用法:
/home/lizhichao/local_remote.vpn 帐号 密码 节点 本地路径 挂盘路径
/home/lizhichao/remote_local.vpn 帐号 密码 节点 盘路径 本地路径
本文来自博客园,作者:BioinformaticsMaster,转载请注明原文链接:https://www.cnblogs.com/koujiaodahan/p/15843107.html
posted on 2022-01-25 15:18 BioinformaticsMaster 阅读(61) 评论(0) 收藏 举报
 
                    
                     
                    
                 
                    
                 
                
            
         
 
         浙公网安备 33010602011771号
浙公网安备 33010602011771号