crt.Screen.WaitForCursor(1) Loop until bCursorMoved = False ‘判定是否已经连接到设备 if crt.Session.Connected = true then ‘断开连接 crt.session.disConnect ‘激活窗口 用于多tab页面 crt.Activate ‘连接到指定设备 crt.session.Connect(“/telnet ” & b(n)) ‘延时1秒 crt.Sleep 1000 2.vbScript语...
# 导入 SecureCRT API 模块# SecureCRT 提供了一系列的 API 接口用于与终端交互defmain():# 获取当前会话对象session=crt.GetCurrentSession()# 发送一个命令到终端# 'ls' 是 Linux 中列出目录内容的命令session.Send("ls\n")# 等待命令执行完成crt.Sleep(1000)# 暂停 1000 毫秒# 从终端获取输出output=sessi...
"crt.Screen.Send"n"&chr(13)crt.Sleep1000crt.Screen.WaitForString">"'记录会话log,选择log文件存储位置,指定设备名为log名crt.Session.LogFileName="X:Documents\script\testlog\"¶ms(4)&".log"’开启log采集crt.Session.Log(True)crt.Screen.Sendchr(13)crt.Screen.WaitForString">"crt.Screen.Send"dis...
crt.Sleep 1000 2.vbScript语句 a.文件操作 Set fso = CreateObject(“Scripting.FileSystemObject”) ‘创建文件对象 Set file1 = fso.OpenTextFile(“c:\test.txt”,1, False) ‘设置文件对象1只读模式;2写模式;8在文件末尾进行写操作 objFso.FileExists(“文件路径”) ‘判定文件是否存在,存在返回trus,否则返...
使用For循环遍历命令列表 Dim i For i = 0 To UBound(commands) ' 发送当前命令到远程会话 crt.Screen.Send commands(i) & vbCrLf ' 可选:等待提示符出现(假设提示符为">") crt.Screen.WaitForString ">" ' 可选:在发送下一条命令前等待一段时间 WScript.Sleep 1000 ' 等待1秒 Next End ...
# $language = "VBScript" # $interface = "1.0" ' Connect to a remote server crt.Session.Connect "/S server_ip_address /L username /P password" ' Wait for the connection to be established crt.Sleep 1000 ' Send some commands to the remote server crt.Screen.Send "ls" & vbCr crt....
crt.Sleep1000 2.vbScript语句 a.文件操作 Setfso=CreateObject("Scripting.FileSystemObject")'创建文件对象 Setfile1=fso.OpenTextFile("c:\test.txt",1,False)'设置文件对象1只读模式;2写模式;8在文件末尾进行写操作 objFso.FileExists("文件路径")'判定文件是否存在,存在返回trus,否则返回false file1....
erro_c =1'---1'loop'crt.Screen.Synchronous = False'crt.Sleep 1000crt.Screen.Send"d 0xfa050100"& chr(13) crt.Sleep100crt.Screen.Send"d 0xfa050100"& chr(13) crt.Screen.waitForString"fa050100: 0000 0002 0002 28b0 0000 ffff"crt.Screen.waitForString"value = 21 = 0x15"crt.Sleep...
if (crt.Screen.WaitForString("]$", 5)<>False)Then 'crt.sleep 1000 crt.Screen.Send"cd /data/log/big-screen-zd"& chr(13) crt.Screen.Send"tail -f big-screen-zd.log"& chr(13) EndIf EndIf EndSub 代码说明:登录服务器后,再跳转196.166.36.60,并查看日志big-screen-zd.log...
# example_script.pydefconnect_and_run_commands(hostname,username,password,commands):# 登录设备crt.Session.Connect(f"ssh2://{username}:{password}@{hostname}")forcommandincommands:crt.Session.Send(command+"\r")# 等待命令完成crt.Sleep(1000)# 获取并打印输出output=crt.Session.ReadString("prompt>...