文件: upload.sh
創(chuàng)新互聯(lián)建站專注于山陽企業(yè)網(wǎng)站建設(shè),成都響應(yīng)式網(wǎng)站建設(shè)公司,商城網(wǎng)站開發(fā)。山陽網(wǎng)站建設(shè)公司,為山陽等地區(qū)提供建站服務(wù)。全流程按需設(shè)計,專業(yè)設(shè)計,全程項目跟蹤,創(chuàng)新互聯(lián)建站專業(yè)和態(tài)度為您提供的服務(wù)
路徑:$HOME/ggscript/ggupload
功能:該腳本不會直接使用,為滿足其他腳本進(jìn)行信息上傳而設(shè)計,在腳本內(nèi)直接調(diào)用上傳相應(yīng)的文件信息
他會讀取系統(tǒng)信息配置文件sysinfo內(nèi)的系統(tǒng)配置信息
范例
[detest#]
Ip-MTMyLjEyMS4xMDEuODYK
UserName-Z2dzCg==
PassWord-Z2dzxxxxxx
Port-MjIK
path-L2RhdGExL2dncy9nZ3NlcnZlci9kaXJkZWYK
[#detest]
以上信息以base64進(jìn)行加密,保證信息安全,獲取IP 用戶名,密碼,以及端口路徑
并將相應(yīng)的文件下發(fā)至對應(yīng)的機器
#!/bin/bash if [ $# -eq 0 ]; then echo "info host file checkf" exit 2 fi if [ $# -eq 1 ]; then echo "info host file checkf" exit 2 fi if [ $# -eq 1 ]; then echo "info host file checkf" exit 2 fi host=$1 file=$2 checkf=$3 cd $HOME/ggscript/ggupload #sed '/"$host"/,/5/p' $checkf > infotmp cat $HOME/ggscript/ggupload/$checkf | awk '/'$host'#/,/#'$host'/{if(i>1)print x;x=$0;i++}' > $HOME/ggscript/ggupload/infotmp ip=`cat $HOME/ggscript/ggupload/infotmp|grep -w "Ip"|cut -d "-" -f 2` pw=`cat $HOME/ggscript/ggupload/infotmp|grep -w "PassWord"|cut -d "-" -f 2` port=`cat $HOME/ggscript/ggupload/infotmp|grep -w "Port"|cut -d "-" -f 2` us=`cat $HOME/ggscript/ggupload/infotmp|grep -w "UserName"|cut -d "-" -f 2` path=`cat $HOME/ggscript/ggupload/infotmp|grep -w "path"|cut -d "-" -f 2` echo "code" echo "ip=$ip" echo "pw=$pw" echo "port=$port" echo "user= $us" echo "path=$path" echo $ip > tmp perl -MMIME::Base64 -ne 'print decode_base64($_)' < tmp > out ip=`cat out` echo $pw > tmp perl -MMIME::Base64 -ne 'print decode_base64($_)' < tmp > out pw=`cat out` echo $port > tmp perl -MMIME::Base64 -ne 'print decode_base64($_)' < tmp > out port=`cat out` echo $us > tmp perl -MMIME::Base64 -ne 'print decode_base64($_)' < tmp > out us=`cat out` echo $path > tmp perl -MMIME::Base64 -ne 'print decode_base64($_)' < tmp > out path=`cat out` #echo "decode" #echo "ip=$ip" #echo "pw=$pw" #echo "port=$port" #echo "user=$us" #echo "path=$path" while [ ${#port} -le 1 ] do port=22 done #echo $ip $pw $port $path expect -c " spawn scp -r -P $port $file $us@$ip:$path expect { \"*assword\" {set timeout 300; send \"$pw\r\";} \"yes/no\" {send \"yes\r\"; exp_continue;} } expect eof"