文件: upload.sh
路径:$HOME/ggscript/ggupload
功能:该脚本不会直接使用,为满足其他脚本进行信息上传而设计,在脚本内直接调用上传相应的文件信息
他会读取系统信息配置文件sysinfo内的系统配置信息
范例
[detest#]
Ip-MTMyLjEyMS4xMDEuODYK
UserName-Z2dzCg==
PassWord-Z2dzxxxxxx
Port-MjIK
path-L2RhdGExL2dncy9nZ3NlcnZlci9kaXJkZWYK
[#detest]
以上信息以base64进行加密,保证信息安全,获取IP 用户名,密码,以及端口路径
并将相应的文件下发至对应的机器
#!/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"
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。