#!/bin/bash
#0 0 1,10,22 * * /it_data3/h3c_backup.sh & #添加到计划任务
datetime=`date +%Y%m%d`
BAKTIME=`date +%Y%m%d%H%M%S`
user="admin"
password="123456"
back="dis cu"
BAK_DIR=/it_data3/H3C_back
mkdir $BAK_DIR/MY_H3C_$datetime
for i in $(cat h3c_ip_file)
do
ping -c 10 $i >/it_data3/cc
ping_fail=$(cat /it_data3/cc | grep Unreachable | awk '{print $6}' |tail -1)
if [[ $ping_fail == Unreachable ]] ;
then
ping -c 50 $i
else
echo "PING_SUSS"
fi
{
echo $user;
sleep 1;
echo $password;
sleep 1;
echo $back;
sleep 1;
echo " ";
sleep 5;
}|telnet $i > $BAK_DIR/MY_H3C_$datetime/$i-$BAKTIME.cfg
tail -n +18 $BAK_DIR/MY_H3C_$datetime/$i-$BAKTIME.cfg > $BAK_DIR/MY_H3C_$datetime/MY-$i-$BAKTIME.cfg
rm -rf $BAK_DIR/MY_H3C_$datetime/$i-$BAKTIME.cfg
done