!/bin/bash
for devicename in ${DEVICENAME[@]}
do
echo "data +%H:%M:%S
开始备份$devicename"
IPADDR=(cat /home/Network_Config_Backup/usr.password | grep "$devicename" |awk ‘{print $3}‘
)
USERNASME=(cat /home/Network_Config_Backup/usr.password | grep "$devicename" |awk ‘{print $4}‘
)
PASSWORD=(cat /home/Network_Config_Backup/usr.password | grep "$devicename" |awk ‘{print $5}‘
)
TABLE=(cat /home/Network_Config_Backup/usr.password | grep "$devicename" |awk ‘{print $2}‘
)
if [ $TABLE = cisco ]
then
/usr/bin/expect >> /dev/null <<EOF
set timeout 10
spawn telnet $IPADDR
expect "username:"
send "$USERNASME\r"
expect "password:"
send "$PASSWORD\r"
expect {
">" {
send "enable\r"
expect "password"
send "$PASSWORD\r"
expect "*#"