" crt.Screen.Send"su"&VbCr crt.Screen.Wait"> " crt.Screen.Send"su"&VbCr crt.Screen.Wait" />
欢迎来到天天文库
浏览记录
ID:57690548
大小:15.00 KB
页数:2页
时间:2020-09-01
《SecureCRT脚本实现自动备份华为交换机配置.doc》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、下面这个脚本能批量对交换机做配置备份工作,在使用时请根据情况更改脚本中交换机的登录密码如下位置 crt.Screen.WaitForString">" crt.Screen.Send"su"&VbCr crt.Screen.WaitForString"Password:" crt.Screen.Send"huawei"&VbCr crt.Screen.WaitForString">"其中,name.txt文件就是一行一个交换机的IP地址,如:172.16.1.1172.16.1.2---------------------------------------------
2、---------------请将下列脚本保存为*.VBS文件----- #$language="VBScript"#$interface="1.0"'Thisscriptshowshowtoreadinafile,anditdemonstrateshowto'performsomepreprocessingondata(splittingthefiledatainto'separatestrings)beforesendingittoaserver.'ConstantusedbyOpenTextFile()ConstForReading=1Submain 'Openafile,
3、readitin&senditonelineatatime Dimfso,f Setfso=CreateObject("Scripting.FileSystemObject") Setf=fso.OpenTextFile("d:ame.txt",ForReading,0) Dimline,params DoWhilef.AtEndOfStream True 'Readeachlineoftheprintersfile. ' line=f.Readline 'Splitthelineup.Eachlineshouldcontain3space-separate
4、dparameters params=Split(line) 'params(0)holdsparameter1,params(1)holdsparameter2,etc. ' 'Send"mycommand"withtheappendedparametersfromthefilewith 'anappendedCR. ' crt.Screen.Send"telnet"¶ms(0)&"" &vbCR 'waitforswitchprompt crt.Screen.WaitForString"Username:" crt.Screen.Send"ad
5、min"&VbCr 'Waitforatringthatlookslike"password:"or"Password:" crt.Screen.WaitForString"Password:" 'Sendyourpasswordfollowedbyacarriagereturn crt.Screen.Send"admin"&VbCr crt.Screen.WaitForString">" crt.Screen.Send"su"&VbCr crt.Screen.WaitForString"Password:" crt.Screen.Send"huawei
6、"&VbCr crt.Screen.WaitForString">" 'executesomecommands crt.Screen.Send"tftp172.16.1.250putvrpcfg.cfg"¶ms(0)&".txt" &VbCr crt.Screen.Send"quit"&VbCr 'leaveoutswitch,stayinlinux crt.Screen.WaitForString"#",3 'Causea3-secondpausebetweensendsbywaitingforsomething"unexpected" 'w
7、ithatimeoutvalue. LoopEndSub
此文档下载收益归作者所有