码迷,mamicode.com
首页 > Web开发 > 详细

SecureCRT中使用VBs脚本自动telnet登陆

时间:2017-02-23 18:41:01      阅读:303      评论:0      收藏:0      [点我收藏+]

标签:call   ssi   screen   ffffff   san   white   nec   password   blog   

查看SecureCRT帮助文档:

Help-> Help Topics->Scripting -> Script Objects Reference -> Session Object

#$language = "VBScript"
#$interface = "1.0"

crt.Screen.Synchronous = True

 This automatically generated script may need to be edited in order to work correctly.

Sub Main
    for i = 0 to 100
    crt.Session.Disconnect
    crt.Session.Connect("/TELNET 192.168.1.1")
    crt.Screen.WaitForString "login:"
    crt.Screen.Send "root" & chr(13)
    crt.Screen.WaitForString "Password:"
    crt.Screen.Send "123456" & chr(13)
    crt.Screen.WaitForString "root@server:" 
    crt.Screen.Send "df" & chr(13)
    crt.Screen.WaitForString "root@server:" 
    crt.sleep 1000
    next
End Sub

上述脚本也可以把登陆部分放在for循环外面,只是在一台机器上反复执行一条命令隔1秒.

#$language = "VBScript"
#$interface = "1.0"
 
crt.Screen.Synchronous = True
 
 This automatically generated script may need to be edited in order to work correctly.
 
Sub Main
         Dim i
         i = 10
         Do While i > 0
                   crt.Screen.Send "df" & chr(13)
                   crt.Screen.WaitForString "root@server:"
                   crt.Screen.Send "echo ok" & chr(13)
                   crt.Screen.WaitForString "root@server:"           
                   crt.Sleep 1000
                   i=i-1
         Loop
End Sub

提示符root@ubuntu:~#,可以写成crt.Screen.WaitForString "root@ubuntu:" 
crt.sleep 1000  ‘sleep 1 seconds

也可以自己录制一个脚本:Script-> Start Recording Script,停止,保存,运行即可。

CRT也支持Python,更加灵活。

SecureCRT中使用VBs脚本自动telnet登陆

标签:call   ssi   screen   ffffff   san   white   nec   password   blog   

原文地址:http://www.cnblogs.com/v5captain/p/6434704.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!