GNS和konsole结合脚本使用的问题

其它类软件,非上述版软件
回复
头像
B05021229
帖子: 17
注册时间: 2010-10-13 16:54
送出感谢: 0
接收感谢: 1 次

GNS和konsole结合脚本使用的问题

#1

帖子 B05021229 » 2011-02-26 0:03

以前在windows里使用GNS3 是结合secureCRT 使用,只要在终端命令中添加
一下脚本就可以实现自动输入一些命令。但是现在使用Ubuntu中的GNS3和konsole结合用,这个脚本应该如何写?

SecureCRT.vbs 如下

代码: 全选

#$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","December")

   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.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 Sub
顺便学习一下怎么写脚本。
粽子最坏也就是被人吃掉了。
回复

回到 “其它类软件”