首页 > 代码库 > SecureCRT中使用VBs脚本自动telnet登陆
SecureCRT中使用VBs脚本自动telnet登陆
查看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 nextEnd 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 LoopEnd Sub
提示符root@ubuntu:~#,可以写成crt.Screen.WaitForString "root@ubuntu:"
crt.sleep 1000 ‘sleep 1 seconds
也可以自己录制一个脚本:Script-> Start Recording Script,停止,保存,运行即可。
CRT也支持Python,更加灵活。
SecureCRT中使用VBs脚本自动telnet登陆
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。