亚洲av成人无遮挡网站在线观看,少妇性bbb搡bbb爽爽爽,亚洲av日韩精品久久久久久,兔费看少妇性l交大片免费,无码少妇一区二区三区

  免費注冊 查看新帖 |

Chinaunix

  平臺 論壇 博客 文庫
最近訪問板塊 發(fā)新帖
查看: 1901 | 回復: 0
打印 上一主題 下一主題

從服務器能夠到達的所有網絡設備里面提取設備配置信息 [復制鏈接]

論壇徽章:
1
15-16賽季CBA聯賽之北控
日期:2022-03-04 22:35:50
跳轉到指定樓層
1 [收藏(0)] [報告]
發(fā)表于 2008-03-26 19:27 |只看該作者 |倒序瀏覽

本工具用于從網絡設備(CISCO)中提取配置文件,并保存到一個文本文件中。
需要 expect 軟件支持, 如果你的操作系統(tǒng)沒有這個軟件,請根據需要下載
在 sco unix 中,請到

http://www.sco.com/skunkware/
中下載, 三個軟件: expect , tcl, tk 并安裝。
主程序-----dome.sh
#!/bin/sh
counter=0
Usage()
{
echo "
Usage: $0 [iplist_filename]
功能:本程序用于讀網絡設備的配置信息。
參數: iplist_filename, 指定需要工作的網絡設備文件。
文件格式:
節(jié)點編號 ip地址 Telnet密碼 超級用戶密碼 節(jié)點設備說明
如果沒有定義iplist_filename, 缺省文件名為:iplist
程序輸入文件: iplist.out 或者 自定義文件名.out \n\n"
exit 1
}
[ $# -eq 0 ] && input="iplist"
[ $# -eq 1 ] && input=$1
[ $# -gt 1 ] && Usage
output="$input.out"
[ -r $input ] || {
echo "Error: Can't open file:$input"
exit 1
}
echo "">$output
lines=`wc -l $input|awk '{ print $1 }'`
while read node host pass1 pass2 name
do
counter=`expr $counter + 1 `
echo "\nGet configure from [ $host ], Please wait...\t[$counter/$lines]\c">&2
echo "============== begin ==============================\n">>$output
echo "NODE=$node">>$output
echo "NAME=$name">>$output
./router.cmd $host $pass1 $pass2>>$output
case $? in
0) echo "\t----\c">&2; continue;;
1) echo "\tE--- error \c">&2; continue;;
2) echo "\t-E-- error \c">&2; continue;;
3) echo "\t--E- error \c">&2; continue;;
4) echo "\t---E error \c">&2; continue;;
*) echo "\t**** error \c">&2; continue;;
esac
echo "-------------- end --------------------------------\n">>$output
done&2
:em02: [b:7ce538da72]調用程序 router.cmd [/b:7ce538da72]
#!/usr/local/bin/expect --
# 登陸路由器的一個命令 script for expact
# 重要變量說明:
# routerip=路由器telnet登陸ip地址
# passwd1=路由器telnet登陸密碼
# passwd2=路由器超級用戶密碼
# ---------------------------------------------------
if $argc!=3 {
send_user "Usage: router.cmd routerip passwd1 passwd2\n"
exit 9
}
set ROUTERIP [lindex $argv 0]
set PASSWORD1 [lindex $argv 1]
set PASSWORD2 [lindex $argv 2]
set TIMEOUT 30
set debug_flag 1
send_user "##### BEGIN\n"
spawn /usr/bin/telnet $ROUTERIP 23
set timeout $TIMEOUT
expect {
timeout {
send_user "Error 1: router ip can't arrived.\n"
send_user "##### END\n\n"
exit 1
}
"refused" {
send_user "Error 1: connection Failed.\n"
send_user "##### END\n\n"
exit 1
}
"*assword: " { send "$PASSWORD1\r" }
}
set timeout $TIMEOUT
expect {
timeout {
send_user "\nError 2: invalid telnet password...\n"
send_user "##### END\n\n"
exit 2
}
"*>" { send "enable\r" }
}
set timeout $TIMEOUT
expect {
timeout {
send_user "\nError 3: time out.\n"
send_user "##### END\n\n"
exit 3
}
"Password: " { send "$PASSWORD2\r" }
}
set timeout $TIMEOUT
expect {
timeout {
send_user "\nError 4: Invalid password for super user...\n"
send_user "##### END\n\n"
exit 3
}
"*#" { send "term len 0 \r" }
}
expect "*#"
send "show run\r"
expect "*#"
send "exit\r"
send_user "\n##### END\n\n"
exit 0
=============以上程序已經在。樱悖铩。眨睿椋。希樱遥怠±锩鏈y試通過


本文來自ChinaUnix博客,如果查看原文請點:http://blog.chinaunix.net/u/31/showart_509080.html
您需要登錄后才可以回帖 登錄 | 注冊

本版積分規(guī)則 發(fā)表回復

  

北京盛拓優(yōu)訊信息技術有限公司. 版權所有 京ICP備16024965號-6 北京市公安局海淀分局網監(jiān)中心備案編號:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年舉報專區(qū)
中國互聯網協會會員  聯系我們:huangweiwei@itpub.net
感謝所有關心和支持過ChinaUnix的朋友們 轉載本站內容請注明原作者名及出處

清除 Cookies - ChinaUnix - Archiver - WAP - TOP