Linux機器間同步文件腳本

創建文件rsync_file.exp,寫入以下內容:

文件內容中’123’爲要上傳主機 [email protected] 的用戶密碼

#!/usr/bin/expect  -- 
#exp_internal 1
#set timeout -1 
set timeout 600

set outpath [lindex $argv 1]:[lindex $argv 2]
set localpath [lindex $argv 0] 
spawn rsync -avuP $localpath $outpath

    expect  {
                    "assword:" {
                                send "123\r" 
                                expect eof 
                                }
                     "yes/no)?" {
                                send "yes\r"        
                                }
                    timeout {exit 2}
            }

執行以下命令執行腳本:

./rsync_file.exp localfile vitamin@192.163.0.1 uploaddir/filename
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章