亚洲免费乱码视频,日韩 欧美 国产 动漫 一区,97在线观看免费视频播国产,中文字幕亚洲图片

      1. <legend id="ppnor"></legend>

      2. 
        
        <sup id="ppnor"><input id="ppnor"></input></sup>
        <s id="ppnor"></s>

        expect實(shí)現(xiàn)單臺、多臺服務(wù)器批量scp傳輸文件

        字號:


            今天公司同事要在一臺服務(wù)器上對另外兩臺同機(jī)房的服務(wù)器進(jìn)行文件傳輸,兩臺服務(wù)器的文件存放地址一致,密碼和key也一致(我們公司在安全上做得有點(diǎn)變態(tài)的),為了效率寫了下面這個腳本.
            1.單臺傳輸腳本
            cat /root/soft_shell/allscp.sh
            復(fù)制代碼 代碼如下:#!/usr/bin/expectif {$argc < 2} { send_user "usage: $argv0 src_file username ip dest_file password\n"exit}##set key [lindex $argv 0]set src_file [lindex $argv 0]set username [lindex $argv 1]set host_ip [lindex $argv 2]set dest_file [lindex $argv 3]set password [lindex $argv 4]##spawn scp -i $key $src_filespawn scp $src_file expect { "(yes/no)?" { send "yes\n" expect "password:" {send "$password\n"} } "password:" { send "$password\n" }}expect "100%"expect eof
            2.多臺傳輸腳本
            cat /root/soft_shell/mainscp.sh
            復(fù)制代碼 代碼如下:#!/bin/bashhost_list="server_list.conf"cat $host_list | while read linedo host_ip=`echo $line|awk '{print $1}'` username=`echo $line|awk '{print $2}'` password=`echo $line|awk '{print $3}'` src_file=`echo $line|awk '{print $4}'` dest_file=`echo $line|awk '{print $5}'` ##key=`echo $line|awk '{print $6}'` ##./allscp.sh $key $src_file $username $host_ip $dest_file $password ./allscp.sh $src_file $username $host_ip $dest_file $passworddone
            3.服務(wù)器信息文件
            復(fù)制代碼 代碼如下:cat /root/soft_shell/server_list.conf
            格式為:
            復(fù)制代碼 代碼如下:ip 用戶名 密碼 源文件 目標(biāo)文件地址
            ps:以上3個文件,相信大家都看出來了,都是放在同一文件夾下面的.我本地測試只用ssh密碼,沒有加上ssh key,如果要用上跟我們公司正式環(huán)境一樣的安全方式(ssh密碼+key,才能登錄服務(wù)器),那么請自己修改腳本文件,我比較懶這里就不說得那么詳細(xì)了.
            最后來張效果圖吧,免得大家說我腳本有問題.