码迷,mamicode.com
首页 > 其他好文 > 详细

spawn ssssssssssssssssssssh

时间:2018-11-22 20:43:22      阅读:150      评论:0      收藏:0      [点我收藏+]

标签:time   tee   %s   work   one   dos   targe   pdo   expec   

[root@ChrisTest spawnL2SW_sh_ip_int_b]# cat doshow.sh
#!/usr/bin/expect -f

set time 10
set passwd "SMBC2012"
set passwd2 "smbc@dmin"
set passwd2en "smbc@dminen"
set prompt "CNAPS-UAT-SW01.>$"
set prompt2 "SH.
S.>$"
set prompt2en "SH.
S.#$"
set HOSTNAME [lindex $argv 0]
spawn ssh admin@10.116.12.250
expect {
"
yes/no" { send "yes\r"; exp_continue }
"Password:" { send "$passwd\r" }
}
expect -re "$prompt"
send "ssh $HOSTNAME\n"
expect {
"
yes/no" { send "yes\r"; exp_continue }
"*Password:" { send "$passwd2\r" }
}
expect -re "$prompt2"
send "enable\n"
expect "Password:"
send "$passwd2en\n"
expect -re "$prompt2en"
send "ter len 0\n"
expect -re "$prompt2en"
send "sh ip int b\n"
expect -re "$prompt2en"
send "exit\r"

[root@ChrisTest spawnL2SW_sh_ip_int_b]# cat maindoshowall.sh
#!/bin/sh
LIST=./SWlist.txt
DATE=`date ‘+%Y-%m-%d
%H:%M:%S‘<br/>mkdir ./worklog_$DATE<br/>for TARGET incat $LIST`
do
echo $TARGET
./doshow.sh $TARGET | tee ./worklog_$DATE/$TARGET.log
done

#./doshow.sh 10.110.104.71 | tee ./worklog_$DATE/10.110.104.71.log

echo ‘ ‘
echo ‘ ‘
echo ‘ ‘
echo ‘ ‘
echo ‘ ‘

SH11ESupupcount=`grep -rnh "GigabitEthernet.up.up" worklog$DATE/10.110.104.7 | wc -l<br/>SH11ESupdown_count=grep -rnh "GigabitEthernet.up.down" worklog_$DATE/10.110.104.7 | wc -l<br/>SH11ESdownup_count=grep -rnh "GigabitEthernet.down.up" worklog_$DATE/10.110.104.7 | wc -l<br/>SH11ESdowndown_count=grep -rnh "GigabitEthernet.down.down" worklog_$DATE/10.110.104.7 | wc -l`

SH11WSupupcount=`grep -rnh "GigabitEthernet.up.up" worklog$DATE/10.110.104.8 | wc -l<br/>SH11WSupdown_count=grep -rnh "GigabitEthernet.up.down" worklog_$DATE/10.110.104.8 | wc -l<br/>SH11WSdownup_count=grep -rnh "GigabitEthernet.down.up" worklog_$DATE/10.110.104.8 | wc -l<br/>SH11WSdowndown_count=grep -rnh "GigabitEthernet.down.down" worklog_$DATE/10.110.104.8 | wc -l`

echo "11F East Area UP\/UP count=$SH11ESupupcount" >> ./worklog$DATE/Count_Statistics
echo "11F East Area UP\/DOWN count=$SH11ESupdowncount" >> ./worklog$DATE/Count_Statistics
echo "11F East Area DOWN\/UP count=$SH11ESdownupcount" >> ./worklog$DATE/Count_Statistics
echo "11F East Area DOWN\/DOWN count=$SH11ESdowndowncount" >> ./worklog$DATE/Count_Statistics

echo "11F West Area UP\/UP count=$SH11WSupupcount" >> ./worklog$DATE/Count_Statistics
echo "11F West Area UP\/DOWN count=$SH11WSupdowncount" >> ./worklog$DATE/Count_Statistics
echo "11F West Area DOWN\/UP count=$SH11WSdownupcount" >> ./worklog$DATE/Count_Statistics
echo "11F West Area DOWN\/DOWN count=$SH11WSdowndowncount" >> ./worklog$DATE/Count_Statistics

grep -r "GigabitEthernet.down.down" worklog$DATE/10.110.104.* | awk -F"/" ‘{print $2,$3,$4}‘ >./worklog$DATE/11FDownDownPorts.txt

exit 1

[root@ChrisTest spawnL2SW_sh_ip_int_b]# cat SWlist.txt
10.110.104.71
10.110.104.72
10.110.104.73
10.110.104.74
10.110.104.75
10.110.104.76
10.110.104.81
10.110.104.82
10.110.104.83
10.110.104.84
10.110.104.85
10.110.104.86
[root@ChrisTest spawnL2SW_sh_ip_int_b]# cat worklog_2018-11-20_15\:54\:28/
10.110.104.71.log 10.110.104.75.log 10.110.104.83.log 11FDownDownPorts.txt
10.110.104.72.log 10.110.104.76.log 10.110.104.84.log Count_Statistics
10.110.104.73.log 10.110.104.81.log 10.110.104.85.log
10.110.104.74.log 10.110.104.82.log 10.110.104.86.log
[root@ChrisTest spawnL2SW_sh_ip_int_b]# cat worklog_2018-11-20_15\:54\:28/Count_Statistics
11F East Area UP\/UP count=197
11F East Area UP\/DOWN count=0
11F East Area DOWN\/UP count=0
11F East Area DOWN\/DOWN count=115
11F West Area UP\/UP count=217
11F West Area UP\/DOWN count=0
11F West Area DOWN\/UP count=0
11F West Area DOWN\/DOWN count=95

[root@ChrisTest spawnL2SW_sh_ip_int_b]# cat worklog_2018-11-20_15\:54\:28/11FDownDownPorts.txt
10.110.104.71.log:GigabitEthernet1 0 2 unassigned YES unset down down
10.110.104.71.log:GigabitEthernet1 0 4 unassigned YES unset down down
10.110.104.71.log:GigabitEthernet1 0 5 unassigned YES unset down down
10.110.104.71.log:GigabitEthernet1 0 6 unassigned YES unset down down
10.110.104.71.log:GigabitEthernet1 0 7 unassigned YES unset down down
10.110.104.71.log:GigabitEthernet1 0 8 unassigned YES unset down down
10.110.104.71.log:GigabitEthernet1 0 9 unassigned YES unset down down
10.110.104.71.log:GigabitEthernet1 0 10 unassigned YES unset down down
10.110.104.71.log:GigabitEthernet1 0 11 unassigned YES unset down down
10.110.104.71.log:GigabitEthernet1 0 12 unassigned YES unset down down
10.110.104.71.log:GigabitEthernet1 0 13 unassigned YES unset down down
10.110.104.71.log:GigabitEthernet1 0 14 unassigned YES unset down down
10.110.104.71.log:GigabitEthernet1 0 16 unassigned YES unset down down
10.110.104.71.log:GigabitEthernet1 0 17 unassigned YES unset down down
10.110.104.71.log:GigabitEthernet1 0 18 unassigned YES unset down down
10.110.104.71.log:GigabitEthernet1 0 19 unassigned YES unset down down
10.110.104.71.log:GigabitEthernet1 0 20 unassigned YES unset down down
10.110.104.71.log:GigabitEthernet1 0 21 unassigned YES unset down down
10.110.104.71.log:GigabitEthernet1 0 30 unassigned YES unset down down
10.110.104.71.log:GigabitEthernet1 0 32 unassigned YES unset down down
10.110.104.71.log:GigabitEthernet1 0 34 unassigned YES unset down down
10.110.104.71.log:GigabitEthernet1 0 46 unassigned YES unset down down
10.110.104.71.log:GigabitEthernet1 0 48 unassigned YES unset down down
10.110.104.71.log:GigabitEthernet1 0 51 unassigned YES unset down down
10.110.104.71.log:GigabitEthernet1 0 52 unassigned YES unset down down
10.110.104.72.log:GigabitEthernet1 0 4 unassigned YES unset down down
10.110.104.72.log:GigabitEthernet1 0 21 unassigned YES unset down down

spawn ssssssssssssssssssssh

标签:time   tee   %s   work   one   dos   targe   pdo   expec   

原文地址:http://blog.51cto.com/3229026/2320302

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!