#!/bin/bash
var="`date -u \"+%m%d%H%M%Y \"`"
username="gaps"
password="test321"
ip="10.253.0.51"
command1="echo "yes"|date -u "${var}
echo $command1
(
sleep 1;
echo "$username";
sleep 1;
echo "$password";
sleep 1;
echo "$command1";
sleep 1;
echo "yes|head";
sleep 1;
echo "exit" ;
echo "exit") | telnet $ip >>/ddd/shell/1.log
0,30 * * * * sh /woshell/upDate.sh
---------------------------------------------
$ cat /upload.sh
#!/bin/bash
#此处配置FTP(即要上传到的总公司服务器)IP地址
FTPHOST="10.33.2.123"
#此处配置FTP(即要上传到的总公司服务器)的用户名
USERNAME="test"
#此处配置FTP(即要上传到的总公司服务器)的密码
PASSWORD="test123"
#此处配置备份文件path
LOCALPATH="/w/backupdir"
#此处配置上传到总公司的保存路径(绝对路径)
FTPPATH="/testfs/test/msbak"
#取当天年月日
yt=`date "+%Y"`
mt=`date "+%m"`
if [ $mt = 1 ]; then
m1=12
y1=$(($yt-1))
elif [ $mt = 11 ]||[ $mt = 12 ]; then
m1=$(($mt-1))
y1=$yt
else
m1=0$(($mt-1))
y1=$yt
fi
#文件名信息
SRCFILE="$y1-$m1"
DESFILE="$y1-$m1.tar"
#压缩处理
cd $LOCALPATH
test ! -d $SRCFILE &&echo "error:To upload the backup folder does not exist">>$SRCFILE-upload.log && exit 0
tar -cvf $DESFILE $SRCFILE
/usr/contrib/bin/gzip $DESFILE
DESFILEZIP=$DESFILE.gz
#登入FTP Server并传送文件
ftp -n<
open $FTPHOST
user $USERNAME $PASSWORD
binary
cd $FTPPATH
lcd $LOCALPATH
prompt
put $DESFILEZIP $DESFILEZIP
close
bye
!
rm -f $DESFILEZIP
cd ..
echo "Uploaded successfully">>$SRCFILE-upload.log$
阅读(1298) | 评论(0) | 转发(0) |