資源描述:
《SecureCRT腳本實現(xiàn)自動備份華為交換機配置.doc》由會員上傳分享,免費在線閱讀,更多相關(guān)內(nèi)容在教育資源-天天文庫。
1、下面這個腳本能批量對交換機做配置備份工作,在使用時請根據(jù)情況更改腳本中交換機的登錄密碼如下位置???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