华为交换机自动透传vbs脚本1.doc_第1页
华为交换机自动透传vbs脚本1.doc_第2页
华为交换机自动透传vbs脚本1.doc_第3页
华为交换机自动透传vbs脚本1.doc_第4页
免费预览已结束,剩余1页可下载查看

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

单个华为交换机自动透传vlan工具:secureCRT 语言:vbs 作者:鲍继川 邮箱:1. Vlan.txt 文件Xxxx_93062012G1/0/0 G1/0/2 g1/0/3第一行为交换机名称第二行为vlan第三行为要透传的端口2 交换机信息文件 交换机.txt 用户名 密码 super3密码 用户名 密码 super3密码3 通过读取vlan.txt 文件的第一行,找到交换机信息文件里德信息后登陆进去,取得vlan.txt的第二行为vlan信息。取得第三行作为交换机端口,准备透传。完整代码如下:# $language = VBScript# $interface = 1.0Sub Main Const ForReading = 1, ForWriting = 2, ForAppending = 8Dim objTab,flagon error goto 0flag=0Set objTab = crt.GetScriptTab Set fso1 = CreateObject(Scripting.FileSystemObject) Set fso4 = CreateObject(Scripting.FileSystemObject)objTab.Screen.Synchronous = Truestr1=e:/easy/vlan.txt if not fso1.FileExists(str1) then crt.Dialog.MessageBox 交换机透传文件不存在 & vbcrlf & _ vbcrlf & _ str1 & vbcrlf & vbcrlf & _ 请重新运行脚本! exit Subend ifSet file1 = fso1.OpenTextFile(str1,1, False) line1= line1 = Trim(file1.ReadLine)if line1= then crt.Dialog.MessageBox 交换机为空! exit subend ifdim line2,line3,line4str4=E:easy交换机ip.txtSet file4= fso4.OpenTextFile(str4,1, False) do line4=Trim(file4.ReadLine)if(line4=) thenexit subend ifparams=Split(line4)if(line1=params(1) thenflag=1msgbox(flag)exit doend ifloop until file4.AtEndOfStream=Trueif flag=0 thenmsgbox(没找到交换机)exit subend ifline2 = Trim(file1.ReadLine)line3 = Trim(file1.ReadLine)l=Split(line3)if(line2=)then msgbox(vlan为空)exit Sub end ifif(line3=)then msgbox(端口为空)exit Sub end if objTab.session.LogFileName = e:easylog & Date & & params(0) & .txt objTab.session.Log(true) Telnet到这个设备上 objTab.Session.Connect /TELNET & params(0) objTab.Screen.Synchronous = True objTab.Screen.WaitForString Username:objTab.Screen.Send params(1) & chr(13)objTab.Screen.WaitForString Password:objTab.Screen.Send params(2) & chr(13)objTab.Screen.WaitForString objTab.Screen.Send super 3 & chr(13)objTab.Screen.WaitForString Password:objTab.Screen.Send params(3) & chr(13)objTab.Screen.WaitForString objTab.Screen.Send sys & chr(13)objTab.Screen.WaitForString skey=InStr(params(1),5)select case skeycase 0crt.Screen.Send vlan ba & line2 & chr(13)for i=0 to UBound(l)objTab.Screen.WaitForString objTab.Screen.Send int & l(i)&chr(13)objTab.Screen.WaitForString objTab.Screen.Send port tr al vl &line2&chr(13)objTab.Screen.WaitForString objTab.Screen.Send quit&chr(13)nextcase elseobjTab.Screen.Send vlan & line2 & chr(13)for i=0 to UBound(l)objTab.Screen.WaitForString objTab.Screen.Send int & l(i)&chr(13)objTab.Screen.WaitForString objTab.Screen.Send port tr per vl &line2&chr(13)objTab.Screen.WaitForString objTab.Screen.Send quit&chr(13)nextend selectobjTab.Screen.WaitForString objTab.Screen.Send quit & chr(13)objTab.Screen.WaitForString objTab.Screen.Send sa & chr(13)objTab.Screen.WaitForString Are you sure to continue?Y/NobjTab.Screen.WaitForString ,1objTab.Screen.Send y & chr(13)objTab.Screen.WaitForString #, 2objTab.Session.Disconnect file1.Close()Call objTab.Session.Log(False) objTab.Screen.Synchronous = False end Sub实际运行效果如下:* All rights reserved (2003-2009) * Without the owners prior written consent, * no decompiling or reverse-engineering shall be allowed. * Notice: * This is a private communication system. * Unauthorized access or use may lead to prosecution. *Login authenticationUsername:_9306Password:Info: The max number of VTY users is 10, and the number of current VTY users on line is 1.super 3 Password:Warning: Now user privilege is level 3, and only those commands whose level is equal to or less than this level can be used.Privilege note: 0-VISIT, 1-MONITOR, 2-SYSTEM, 3-MANAGEsysEnter system view, return user view with Ctrl+Z._S9306vlan ba 2016 _S9306int g1/0/6_S9306-GigabitEthernet1/0/6port tr al vl 2016 _S9306-GigabitEthernet1/0/6quit_S9306quitsaThe current

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论