files : upload.sh
path : $HOME/ggscript/ggupload
Function: The script will not be used directly, to meet other scripts to upload information and design, directly within the script to upload the corresponding file information
He reads system configuration information in the System Information Profile SysInfo
Example
[detest#]
Ip-mtmyljeyms4xmdeuodyk
username-z2dzcg==
Password-z2dzxxxxxx
Port-mjik
Path-l2rhdgexl2dncy9nz3nlcnzlci9kaxjkzwyk
[#detest]
The above information is encrypted with Base64, ensuring information security, obtaining IP username, password, and port path
#!/bin/bashif [ $# -eq 0 ]; then echo "INFO&NBSP;HOST&NBSP;FILE&NBSP;CHECKF" exit 2fi if [ $# -eq 1 ]; then echo "INFO&NBSP;HOST&NBSP;FILE&NBSP;CHECKF" exit 2fiif [ $# -eq 1 ]; then echo " INFO&NBSP;HOST&NBSP;FILE&NBSP;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 "
This article is from the "Netsman" blog, make sure to keep this source http://netsman.blog.51cto.com/5750076/1939643
Ogg Operations Optimization Script (12)-Information synchronization class--Information upload