关于secureCRT的问题,高手请进,谢谢!
用这个软件登陆网络设备,如路由器后,我进行了一些列的操作,比如查看路由器状态什么的,那么我可以把这些显示的结果保存下来吗?我要做一个脚本,如何制作,我第一次在该软件上查看...
用这个软件登陆网络设备,如路由器后,我进行了一些列的操作,比如查看路由器状态什么的,那么我可以把这些显示的结果保存下来吗?
我要做一个脚本,如何制作,我第一次在该软件上查看了路由器的状态信息,也显示出来了,那么我可以把这个保存作为脚本吗?
以上问题我已经解决了,但是现在又有新问题,我制作了一个脚本后(大概5个命令),在设备上执行脚本,就执行了一个命令,其他的设备都没有问题,这个是什么原因?请知道答案的人帮帮忙!谢谢! 展开
我要做一个脚本,如何制作,我第一次在该软件上查看了路由器的状态信息,也显示出来了,那么我可以把这个保存作为脚本吗?
以上问题我已经解决了,但是现在又有新问题,我制作了一个脚本后(大概5个命令),在设备上执行脚本,就执行了一个命令,其他的设备都没有问题,这个是什么原因?请知道答案的人帮帮忙!谢谢! 展开
2个回答
2009-08-21
展开全部
# $language = "VBScript"
# $interface = "1.0"
Sub main
Dim fso, fHost,fCMDbsn,fCMDscs, strLineHost,strLineCommand,strLogfile,strArray
Const ForReading = 1
Const Hostip=0
Const NodeType=1
Const ScriptPath=""
Set fso = CreateObject("Scripting.FileSystemObject")
ScriptPath=fso.GetParentFolderName(WScript.ScriptFullName)
LogPath=ScriptPath & "\log\"
Set fso = CreateObject("Scripting.FileSystemObject")
Set fHost = fso.OpenTextFile(ScriptPath& "tz.txt", ForReading, 0)
'
Do While fHost.AtEndOfStream <> True
crt.Screen.Synchronous =0
strLineHost = Trim(fHost.Readline )
strArray=split(strLineHost,vbtab,-1)
strLogfile=LogPath & strArray(hostip)
crt.Session.LogFileName = strLogfile
crt.Screen.WaitForString "$"
crt.Session.Log True
crt.Screen.Send "telnet" & " " & strArray(Hostip) & vbcr
crt.screen.waitforstring "ogin:"
crt.screen.send "admin" & vbcr
crt.screen.waitforstring "assword:"
crt.screen.send "admin" & vbcr
If strArray(NodeType)="SW" Then
Set fCMDbsn=fso.OpenTextFile(ScriptPath& "dao_cmd.txt", ForReading, 0)
Do While fCMDbsn.AtEndOfStream <> True
strLineCommand=Trim(fCMDbsn.Readline)
Do While strLineCommand="wait"
crt.sleep 5000
strLineCommand=Trim(fCMDbsn.Readline)
Loop
crt.Screen.WaitforString "#"
crt.Screen.Send strLineCommand & vbcr
call checkend()
Loop
Set fCMDbsn=nothing
Else
Set fCMDscs=fso.OpenTextFile(ScriptPath& "cmdscs.txt", ForReading, 0)
Do While fCMDscs.AtEndOfStream <> True
strLineCommand=Trim(fCMDscs.Readline)
crt.Screen.WaitforString "#"
crt.Screen.Send strLineCommand & vbcr
Loop
Set fCMDscs=nothing
End If
'Logout node
crt.screen.waitforstring "#"
crt.screen.send "quit" & vbcr
crt.screen.send "y" & vbcr
'Stop log file action
crt.screen.waitforstring "$"
crt.screen.send vbcr
crt.Session.Log False
crt.Screen.Synchronous = False
Loop
Set fso=nothing
End Sub
Sub CheckEnd()
Do Until crt.Screen.WaitForString ("#", 1)=True
crt.Screen.Send " "
Loop
crt.Screen.Send vbcr
Exit Sub
End Sub
这是我以前做的一个脚本。供你参考一下。
# $interface = "1.0"
Sub main
Dim fso, fHost,fCMDbsn,fCMDscs, strLineHost,strLineCommand,strLogfile,strArray
Const ForReading = 1
Const Hostip=0
Const NodeType=1
Const ScriptPath=""
Set fso = CreateObject("Scripting.FileSystemObject")
ScriptPath=fso.GetParentFolderName(WScript.ScriptFullName)
LogPath=ScriptPath & "\log\"
Set fso = CreateObject("Scripting.FileSystemObject")
Set fHost = fso.OpenTextFile(ScriptPath& "tz.txt", ForReading, 0)
'
Do While fHost.AtEndOfStream <> True
crt.Screen.Synchronous =0
strLineHost = Trim(fHost.Readline )
strArray=split(strLineHost,vbtab,-1)
strLogfile=LogPath & strArray(hostip)
crt.Session.LogFileName = strLogfile
crt.Screen.WaitForString "$"
crt.Session.Log True
crt.Screen.Send "telnet" & " " & strArray(Hostip) & vbcr
crt.screen.waitforstring "ogin:"
crt.screen.send "admin" & vbcr
crt.screen.waitforstring "assword:"
crt.screen.send "admin" & vbcr
If strArray(NodeType)="SW" Then
Set fCMDbsn=fso.OpenTextFile(ScriptPath& "dao_cmd.txt", ForReading, 0)
Do While fCMDbsn.AtEndOfStream <> True
strLineCommand=Trim(fCMDbsn.Readline)
Do While strLineCommand="wait"
crt.sleep 5000
strLineCommand=Trim(fCMDbsn.Readline)
Loop
crt.Screen.WaitforString "#"
crt.Screen.Send strLineCommand & vbcr
call checkend()
Loop
Set fCMDbsn=nothing
Else
Set fCMDscs=fso.OpenTextFile(ScriptPath& "cmdscs.txt", ForReading, 0)
Do While fCMDscs.AtEndOfStream <> True
strLineCommand=Trim(fCMDscs.Readline)
crt.Screen.WaitforString "#"
crt.Screen.Send strLineCommand & vbcr
Loop
Set fCMDscs=nothing
End If
'Logout node
crt.screen.waitforstring "#"
crt.screen.send "quit" & vbcr
crt.screen.send "y" & vbcr
'Stop log file action
crt.screen.waitforstring "$"
crt.screen.send vbcr
crt.Session.Log False
crt.Screen.Synchronous = False
Loop
Set fso=nothing
End Sub
Sub CheckEnd()
Do Until crt.Screen.WaitForString ("#", 1)=True
crt.Screen.Send " "
Loop
crt.Screen.Send vbcr
Exit Sub
End Sub
这是我以前做的一个脚本。供你参考一下。
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
光派通信
2024-09-03 广告
2024-09-03 广告
对光传输设备进行调试和维护,需要掌握以下关键点:1. **熟悉设备性能**:深入了解OTN/DWDM等光传输产品的性能特点,确保能够熟练使用设备。2. **按规范操作**:依据产品说明书和维护手册进行调试和维护,确保操作步骤正确无误。3. ...
点击进入详情页
本回答由光派通信提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询