@echo "kill CRT process" taskkill /F /IM SecureCRT.exe ::ping 127.0.0.1 -n 30 echo "start vos through CRT" echo off d: cd D:/tools/SecureCRT_x86 start SecureCRT.EXE /SCRIPT D:/Secure_vos/Start_vos.vbs echo "start vos through CRT end" ping 127.0.0.1 -n 4 pause
上述代码的意思是:在.bat文件中执行Start_vos.vbs文件
批处理执行文件之前首先需要下载SecureCRT.exe文件
Start_vos.vbs文件内容如下:
#$language = "VBScript" #$interface = "1.0" crt.Screen.Synchronous = True Sub Main On Error Resume Next Dim result If crt.Session.Connected Then crt.Session.Disconnect ' connected to the '172.21.1.114' Set objtab = crt.Session.ConnectInTab("/SSH2 /PASSWORD root root@172.21.1.114",True) ' Capture error code and description (if any) nError = Err.Number strErr = Err.Description ' Now, tell the script host that it should handle errors as usual now: On Error Goto 0 ' change tab name objtab.caption = "Gdb_vos" ' enter the folder crt.Screen.Send "cd /home/test" & chr(13) crt.Screen.WaitForString chr(27) & "[32m(none) /home/test" & chr(27) & "[m # " End Sub
上述代码主要是将手动输入的过程使用VBS脚本进行自动化
首先:
Set objtab = crt.Session.ConnectInTab("/SSH2 /PASSWORD root123 root@172.11.1.15",True)
采用SSH2的方式连接linuxIP地址
172.21.1.114,密码是root123,用户名是root
objtab.caption = "Start_vos"
将当前连接页面重命名为Start_vos
crt.Screen.Send "cd /home/test" & chr(13)
输入cd /home/test并回车
crt.Screen.WaitForString chr(27) & "[32m(none) /home/test" & chr(27) & "[m # "
等待页面下一行的内容为
chr(27) & "[32m(none) /home/test" & chr(27) & "[m # "
原创文章,作者:奋斗,如若转载,请注明出处:https://blog.ytso.com/193208.html