Chinaunix首页 | 论坛 | 博客
  • 博客访问: 923644
  • 博文数量: 276
  • 博客积分: 4182
  • 博客等级: 上校
  • 技术积分: 4486
  • 用 户 组: 普通用户
  • 注册时间: 2012-04-17 21:14
文章分类

全部博文(276)

文章存档

2014年(9)

2013年(132)

2012年(135)

分类: 系统运维

2012-05-07 19:19:57

H:\SecureCRT\SecureCRT.EXE  /script H:\SecureCRT\vb.vbs /arg %d /T /telnet %h %p

GNS3目录设置

脚本如下 网上CRT脚本无法生成 修改了下

#$language = "VBScript"
#$interface = "1.0"
Option Explicit
Function mysubstring(srcString,bChar,eChar)
  Dim fIndex,sIndex 
  fIndex=InStr(srcString,bChar)
   sIndex=InStrRev(srcString,eChar)
   mysubstring=Mid(srcString,fIndex+1,sIndex-fIndex-1)  
End Function
'用来得到一个时间字符串,该字符串用来设置路由器的时间和日期
Function ciscoDate()
   dim   em, y,m,d,h
   Dim nowDate
   nowDate=Now()
  em=Array

("January","February","March","April","May","June","July","August","September","October","November","Decemb

er")
   y=Year(nowDate) 
   m=em(Month(nowDate)-1)
   d=Day(nowDate) 
   h=Time()
  ciscoDate=h & " " & m & " " & d & " " & y
 
End Function
Sub main
   On Error Resume Next
  
   crt.window.caption = crt.arguments(0)

   crt.Screen.Synchronous = True
   crt.Screen.WaitForString "Console port"
   crt.Screen.Send  VbCr
  
   '得到第一行显示文本,主要从中提取设备名称
   Dim firstLine
   '用来存储标签的标题,也就是设备的名称
   Dim tabTitle
   firstLine=crt.Screen.Get2(1,1,1,100) '得到第一行文本
   tabTitle=mysubstring(firstLine,"""","""") '调用方法取两个双引号之间的文本
   crt.Window.Caption= tabTitle
  
   'Dim result
   'result = crt.screen.WaitForStrings("'yes' or 'no'", "[yes/no]:", "RETURN")
   'If result = 1 Then
   '  crt.Screen.Send VbCr
   'ElseIf result = 2 Then
   '  crt.Screen.Send "no" & VbCr
   'ElseIf result = 3 Then
   '  crt.Screen.Send VbCr  
   'Else
   ' crt.Screen.Send VbCr
   'End If
   If crt.Screen.WaitForString("[yes/no]") Then   
     crt.Screen.Send "no" & VbCr
   End If
   crt.Screen.Send VbCr &VbCr
   crt.Screen.WaitForString "Router>"  
   crt.Screen.Send  "enable" & VbCr
   crt.Screen.Send "conf terminal" & VbCr
   crt.Screen.Send "no ip domain-lookup " & VbCr
   crt.Screen.Send "hostname " & tabTitle & VbCr
   crt.Screen.Send "line con 0" & VbCr  
   crt.Screen.Send "exec-timeout 0 0" & VbCr  
   crt.Screen.Send "logging synchronous" & VbCr     
   crt.Screen.Send "end" & VbCr
  
  crt.Screen.Send "clock set " & ciscoDate() & VbCr 
   crt.Screen.Synchronous = False
 
End

阅读(1256) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~