標籤:og
檔案: upload.sh
路徑:$HOME/ggscript/ggupload
功能:該指令碼不會直接使用,為滿足其他指令碼進行資訊上傳而設計,在指令碼內直接調用上傳相應的檔案資訊
他會讀取系統資訊設定檔sysinfo內的系統配置資訊
範例
[detest#]
Ip-MTMyLjEyMS4xMDEuODYK
UserName-Z2dzCg==
PassWord-Z2dzxxxxxx
Port-MjIK
path-L2RhdGExL2dncy9nZ3NlcnZlci9kaXJkZWYK
[#detest]
以上資訊以base64進行加密,保證資訊安全,擷取IP 使用者名稱,密碼,以及連接埠路徑
並將相應的檔案下發至對應的機器
#!/bin/bashif [ $# -eq 0 ]; then echo "info host file checkf" exit 2fi if [ $# -eq 1 ]; then echo "info host file checkf" exit 2fiif [ $# -eq 1 ]; then echo "info host file checkf" exit 2fihost=$1file=$2checkf=$3cd $HOME/ggscript/ggupload#sed ‘/"$host"/,/5/p‘ $checkf > infotmpcat $HOME/ggscript/ggupload/$checkf | awk ‘/‘$host‘#/,/#‘$host‘/{if(i>1)print x;x=$0;i++}‘ > $HOME/ggscript/ggupload/infotmpip=`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 > tmpperl -MMIME::Base64 -ne ‘print decode_base64($_)‘ < tmp > outip=`cat out`echo $pw > tmpperl -MMIME::Base64 -ne ‘print decode_base64($_)‘ < tmp > outpw=`cat out`echo $port > tmpperl -MMIME::Base64 -ne ‘print decode_base64($_)‘ < tmp > outport=`cat out`echo $us > tmpperl -MMIME::Base64 -ne ‘print decode_base64($_)‘ < tmp > outus=`cat out`echo $path > tmpperl -MMIME::Base64 -ne ‘print decode_base64($_)‘ < tmp > outpath=`cat out`#echo "decode"#echo "ip=$ip"#echo "pw=$pw"#echo "port=$port"#echo "user=$us"#echo "path=$path"while [ ${#port} -le 1 ]doport=22done#echo $ip $pw $port $pathexpect -c " spawn scp -r -P $port $file [email protected]$ip:$path expect { \"*assword\" {set timeout 300; send \"$pw\r\";} \"yes/no\" {send \"yes\r\"; exp_continue;} }expect eof"
本文出自 “netsman” 部落格,請務必保留此出處http://netsman.blog.51cto.com/5750076/1939643
OGG營運最佳化指令碼(十二)-資訊同步類--資訊上傳