1、vbs 脚本在 secureCRT 的应用(设备升级篇)最近在给中兴的 EPON 的 ONU 设备升级,有 113 台设备,没有连接 OLT,主管说让我安装设备之前最好先升级好,以免旧版本的 BUG 会引起客户的不满。于是我用 TFTP 方式按照 TXT 脚本复制给 ONU 升级,升级完后,我发现工作效率极低,因为 ONU 有响应时间,如果用脚本复制进去执行的话,会导致缺损命令,导致多行命令无法一次执行完,必须一条条粘上去,极度影响了工作效率,大概花了一个下午的时间只升级了 7 台设备,这样的工作效率我是无法忍受的。之前看到过 secureCRT 支持 vbs 脚本,但是由于我的编程学的非常差
2、,只能暂时靠 secureCRT 的录制脚本功能,暂时解决升级问题,但是过程中有很多问题,比如每台 ONU 的 mac 地址不同,所以完全按照录制脚本是不行的,必须自己修改。最后我完成了无数次的实验,解决了很多 bug,现在的 vbs 脚本,基本上能够满足我 TFTP 升级 ONU 的工作效率,大概用了四五天的时间,就把 113 台设备升级完毕了。过程只需要插入电源,开启 secureCRT 的连接,最后弹出对话框表示结束,整个升级工作完成,最后把 ONU 和两个 PON 的 mac 地址和编号对应,就行了。以下是 TFTP 升级代码(之前已经在 secureCRT 上设置了初始回车键进入升级
3、模式)?Download update_ZTE_ONU_F809_TFTP.txt123456789101112131415161718192021222324252627282930313233343536373839404142#$language = “VBScript“#$interface = “1.0“crt.Screen.Synchronous = True This automatically generated script may need to be edited in order to work correctly.Sub Maincrt.Screen.Send “c“
4、 chr(13)crt.Screen.WaitForString “ “crt.Screen.Send “192.168.2.99“ chr(13)crt.Screen.WaitForString “ “crt.Screen.Send chr(13)crt.Screen.WaitForString “ “crt.Screen.Send chr(13)crt.Screen.WaitForString “ “crt.Screen.Send “192.168.2.2“ chr(13)crt.Screen.WaitForString “ “crt.Screen.Send chr(13)crt.Scre
5、en.WaitForString “ “crt.Screen.Send chr(13)crt.Screen.WaitForString “The Board WorkType: 0 “crt.Screen.Send chr(13)If crt.Screen.WaitForString(“ok!“F809# “,1)=False Thencrt.Screen.Send “downver MBSS.bin MBSS.bin MBSS“ chr(13)End IfIf crt.Screen.WaitForString(“version download success.“)=True Thencrt
6、.Screen.WaitForString “F809# “crt.Screen.Send “downver MBSS.bak MBSS.bak MBSS“ chr(13)crt.Screen.WaitForString “F809# “crt.Screen.Send “runver“ chr(13)crt.Screen.Send chr(13)crt.sleep 2000crt.Screen.WaitForString “Login:“crt.sleep 1000crt.Screen.Send “admin“ chr(13)crt.Screen.WaitForString “Password
7、:“crt.sleep 1000crt.Screen.Send “admin“ chr(13)crt.Screen.WaitForString “ZXAN“4344454647484950515253545556575859606162636465666768697071727374757677787980818283848586crt.Screen.Send “en“ chr(13)crt.Screen.Send “admin“ chr(13)crt.sleep 1000crt.Screen.WaitForString “ZXAN# “crt.Screen.Send “config“ chr
8、(13)crt.Screen.WaitForString “ZXAN(config)# “crt.Screen.Send “serial attrib basic com_0/3/1 RS485 baud 1200 parity even data 8 stop 1“ chr(13)crt.Screen.WaitForString “ZXAN(config)# “crt.sleep 1000crt.Screen.Send “serial attrib basic com_0/3/2 RS485 baud 1200 parity even data 8 stop 1“ chr(13)crt.Sc
9、reen.WaitForString “ZXAN(config)# “crt.sleep 1000crt.Screen.Send “serial attrib basic com_0/3/3 RS485 baud 1200 parity even data 8 stop 1“ chr(13)crt.Screen.WaitForString “ZXAN(config)# “crt.sleep 1000crt.Screen.Send “serial attrib basic com_0/3/4 RS485 baud 1200 parity even data 8 stop 1“ chr(13)cr
10、t.Screen.WaitForString “ZXAN(config)# “crt.sleep 1000crt.Screen.Send “exit“ chr(13)crt.Screen.WaitForString “ZXAN# “crt.Screen.Send “write“ chr(13)crt.Screen.WaitForString “ZXAN# “crt.Screen.Send “show ver“ chr(13)crt.Screen.WaitForString “ZXAN# “crt.Screen.Send “show run“ chr(13)crt.sleep 1000crt.S
11、creen.Send chr(13)crt.Screen.WaitForString “ZXAN# “crt.Screen.Send “show mac sys“ chr(13)crt.Screen.WaitForString “ZXAN# “crt.Screen.Send “write“ chr(13)crt.Screen.Send chr(13)crt.Dialog.MessageBox“恭喜!固件升级成功!点击【确定】自动断开会话!“crt.Session.Disconnect()ElseIf crt.Screen.WaitForString(“eTSEC1: No link.“)=True Thencrt.sleep 3000crt.Screen.Send chr(13)crt.Screen.WaitForString “version download failed.“crt.Dialog.MessageBox“警告:固件下载失败!点击【确定】将停止脚本运行!“87 crt.Session.Disconnect()crt.quit()End IfEnd Sub
Copyright © 2018-2021 Wenke99.com All rights reserved
工信部备案号:浙ICP备20026746号-2
公安局备案号:浙公网安备33038302330469号
本站为C2C交文档易平台,即用户上传的文档直接卖给下载用户,本站只是网络服务中间平台,所有原创文档下载所得归上传人所有,若您发现上传作品侵犯了您的权利,请立刻联系网站客服并提供证据,平台将在3个工作日内予以改正。