奇科電腦 回奇科電腦首頁奇科電腦LPI課程資訊奇科電腦Embedded課程資訊奇科電腦Cisco課程資訊奇科電腦Programming課程資訊奇科電腦Smartphone App課程資訊
Tech Tips3  How to utilize bash shell script to automatically obtain Cisco Switch and
       Router configuration?

Author: Ben|Date: 2007/06/04|Back to Tech Tips

To obtain Cisco Switch and Router configuration automatically, we can compile one bash shell script combining UNIX CRON to backup configuration regularly:

#!/bin/bash

router=10.10.10.10
password=cisco
enable_mode='enable'
enable_password=cisco
term_length="terminal length"
cmd='show run'

echo open $host
sleep 1
echo $password
sleep 1
echo $enable_mode
sleep 1
echo $enable_password
sleep 1
echo $term_length 0
sleep 1
echo $cmd
sleep 1
echo $term_length 24
sleep 1
echo exit

如果以上的程式名稱為telnet.sh,我們便可以在命令提示字元(prompt)下達指令:

./telnet.sh | telnet

就可以得到IP位址為10.10.10.10的Cisco交換器或是路由器的組態設定了。


Best Browse: 1024x768 Copyright 2010 GeeGo Systems, Ltd.
service@geego.com.tw|DL: 0800-296-296|3F., No.60, Zhulun St., Zhongshan Dist., Taipei City 104, Taiwan (R.O.C.)|02-2711-6373