本文摘自This help manual documents the VanDyke Software® Secure®, version 6.5 terminal emulation A program that emulates a terminal.

SecureCRT is capable of hosting "ActiveX Script" engines. The most common ActiveX script engines are VBScript and JScript (Microsoft’s version of JavaScript), both of which are freely available from Microsoft. Chances are you already have them installed if you’ve installed Internet Explorer 4.0.

ActiveX script engines communicate with SecureCRT via standard interfaces. Therefore, SecureCRT can host any compliant script engine to run your scripts. The advantage of this approach is that you can script SecureCRT using the language of your choice. If an ActiveX script engine is available for your preferred scripting language, you can write scripts that will work with SecureCRT.

Note: To run a logon script in SecureCRT, you must first turn off the Automate logon option in the Connection/Logon Actions category of the Session Options dialog and then, on the same dialog, check the Logon script check box and choose the script that you want to run.

Note2: A script cannot be run from another script. This includes scripts started manually and logon scripts.

Scripts for SecureCRT are text files that you create with your text editor.

A script header is not required as long as the file extension is registered in the registry with a script engine (as common file extensions are). If you want to use a header (for example, if you are using a file without an extension or with an extension that is not common), the header must begin on the first line of the script.

Script headers will be used by SecureCRT to identify which script language the script is written in and the version of SecureCRT scripting interface. Each line of the script header must begin with a (#) character. A SecureCRT script header includes a $language line that identifies the script engine and an $interface line to identify SecureCRT's interface version.

The syntax of the script header is always the same regardless of the script language you are using.

A simple but complete SecureCRT script with a header that identifies it as VBScript is shown below:

# $language = "VBScript"
# $interface = "1.0"
  ' Display SecureCRT's version
  MsgBox "SecureCRT version is: " & crt.Version
End Sub

Sub Main

Note: A SecureCRT script header may also contain blank lines that begin with (#).

The quoted string following $language identifies the script engine. If you are writing scripts that use Microsoft’s JScript language, the appropriate identifier is JScript. If you are using another script engine you’ll need to consult the documentation for the identifier for that language. Currently the script header should specify version 1.0 for $interface. Future versions of SecureCRT may support other versions. The example script above has a subroutine named main where all of the script’s code is located. When SecureCRT executes scripts it always attempts to run a main routine if you have defined one.

It is not a requirement that you place your code within a main however there may be reasons why you would want to do this. The VBScript and JScript engines will parse and execute global script code (script code you have defined outside of any subroutine) before your main is executed. If you have "initialization" code that you want to ensure has been completely executed before your actual script code begins, it may be useful to place your initialization code at the global level. This will ensure that your initialization code will all execute before your main code runs.

Another reason you may want a main routine is to allow your scripts a way of aborting themselves in case of problems. In VBScript there is no built-in way of exiting a script at the global level. However, if you want to exit a subroutine it is possible to use the Exit Sub syntax to do so. For example, in VBScript:

Sub Main

condition = DoSomething()
  If condition = 0 Then
    ' Error, bailout
    Exit Sub
  End If
  
End Sub

When the main routine ends the script has finished running. By placing your code within a main you have the option of invoking Exit Sub whenever it might be necessary.

The previous script samples are written in VBScript. The remainder of code samples in this document are all written in VBScript unless it is stated otherwise. The properties and methods of SecureCRT's interface can be used as documented by any compatible scripting language.

For files stored on NTFS file systems, the script header can optionally be stored in an NTFS alternate data stream called header.txt. One way to do this is to choose Run from the Windows Start menu and enter the following:

notepad myscript.txt:header.txt

Script files can be stored in UTF-8 or Unicode format. Storing a script file in UTF-8 or Unicode format enables characters from languages such as Chinese or Japanese to be included in the script.

For examples of SecureCRT scripts, see the sample scripts in the SecureCRT Installation/Scripts folder and on the VanDyke Software website in the Scripting FAQ section.


Example VBScripts can be found in the SecureCRT installation folder. If you would like to modify an example script, please modify a copy of the script file because if the original scripts are updated, the installer will overwrite the example scripts.

The following are descriptions of the example scripts:

·    AddCommentToLogFile.vbs – This example script allows you to add a custom line of text to your SecureCRT log file.

·    AutoResponder.vbs – Demonstrates how to set up a list of commands/text that get sent to the remote as soon as a corresponding "trigger" string/text is detected from the remote system.

·    BasicReadStringExample.vbs – This example script captures the output of a command (ls -l) sent to a remote machine by using the Screen.ReadString() method. The captured text is then displayed in a message box window.

·    ConnectToMultipleSessionsAndSendCommands.vbs – Reads in sessions from a file (one session per line) and connects to each one (one at a time) and sends a series of commands to the remote, then disconnects from the session and moves on to the next session.

·    CopyOutputToClipboard.vbs – This script example is designed to run while connected to a Cisco Pix firewall or other router device.

·    GoogleSelectedText.vbs – When this script is launched, the text selected within the terminal window is used as the search term for a web search using google.com.

·    LogOutputOfSpecificCommand-UseReadString.vbs – Sends commands one by one as listed in the g_vCommands() array to the remote machine. The results of each command are captured into a variable, and then written to an individual log file (one log file for each command). Once all the commands have been run, Windows Explorer is launched, with the first command output file selected within the explorer window.

·    SaveSelectedTextToFile.vbs – If non-whitespace text is selected within the terminal screen, the user will be prompted for a location and filename in which to store the selected text. The selected text will then be saved to the file specified by the user.

·    SendCommandToAllTabs.vbs – This example script shows how to send the same command to all tabs that currently have an active connection.

·    UseIEAsCustomDialog.vbs – This sample script shows how the Internet Explorer automation object can be used to create custom dialog that can be used within a SecureCRT script.

·    UseIEAsListOutput.vbs – This example script shows how to create a custom dialog using the InternetExplorer.Application ActiveX object. This example also shows how data can be passed between the InternetExplorer object and SecureCRT.

SecureCRT scripting相关推荐

  1. SecureCRT也能和Xshell一样批量导入主机

    在Xshell可以像这样一个文件批量导入主机: https://blog.netsarang.com/91/importing-csv-formatted-host-information-to-xs ...

  2. SecureCRT报错ImportError: No module named itertools(解决方案无法复现)

    ubuntu20.04下面使用SecureCRT报错: (Python3.6) appleyuchi@Desktop:~$ /usr/bin/SecureCRT Traceback (most rec ...

  3. secureCRT思科路由器交换机专用脚本

    为了工作方便,自己写了个脚本用 不过只能在secureCRT上支持Cisco的设备,因为其中的词法分析只适用于Cisco的配置 脚本的功能还行,可以自动识别SSH2和Telnet登录,因为我的工作环境 ...

  4. linux登录交换机备份脚本,自动备份华为交换机配置的SecureCRT的脚本

    昨天升级了40多台华为交换机,幸亏有SecureCRT的快捷键(下篇文章另行介绍),要不然几个小时也搞 不定. 升级完后,对SecureCRT的脚本产生了兴趣,能不能让它自动执行诸如读取.备份配置,升 ...

  5. SecureCRT脚本(VBS)运行

    SecureCRT脚本(VBS)运行 在SecureCRT运行脚本,自动收发数据监控记录运行状态. 参考: 示例代码: #$language = "VBScript" #$inte ...

  6. Microsoft Anti-Cross Site Scripting Library V1.5 发布了

    Microsoft Anti-Cross Site Scripting Library V1.5 发布了 微软反跨站攻击脚本库 v1.5.此下载包含Microsoft Application Secu ...

  7. Mac 安装SecureCRT

    scrt-8.0.2-1118.osx_x64.dmg https://pan.baidu.com/s/1miS5XVy 1.下载破解文件 SecureCRT https://pan.baidu.co ...

  8. ubuntu设置securecrt串口权限

    在普通用户的模式下,用SecureCRT链接串口交换机,开始会提示/dev/ttyUSB0权限不足,无法打开,临时的解决办法是 chmod 0+rw /dev/ttyUSB0 但是这个重启后便没了作用 ...

  9. 虚拟机安装CentOS以及SecureCRT设置【完美无错版】

    一.CentOS简介 CentOS是Linux的发行版之一,它安全.稳定.高效,是我最喜欢的Linux发行版之一.CentOS根据Red Hat Enterprise Linux开放源代码编译而成,与 ...

最新文章

  1. Distributed Configuration Management Platform(分布式配置管理平台)
  2. 最优化——对偶问题的性质(弱对偶性,强对偶性),对偶问题形式的书写(对偶规则)
  3. python中的字典推导式_17.python 字典推导式(经典代码)
  4. php获取到的json数据如何处理_php – 如何从API获取JSON数据
  5. 用户修改了信息jwt服务器怎么识别,jwt验证登录信息
  6. Java基础整理(二)
  7. 67. 查询分页数据(2)
  8. (27)python-多维数组
  9. 毕业设计—基于FPGA的极化码译码研究
  10. Unity 粒子特效相对位置和大小的调整
  11. 微信小程序如何实现搜索框的防抖功能
  12. Python学习(八):返回值变量的作用域参数的传递浅拷贝和深拷贝类对象和方法
  13. 2020-09-04 CD40193十六进制加减Multisim仿真
  14. 医疗器械小程序或手机APP软件开发方案
  15. MATLAB | MATLAB中绘图的奇淫技巧合集
  16. 进程相关概念(一文搞懂)
  17. Kotlin骚气写法 三
  18. CVE-2018-4990 漏洞详情分析
  19. 什么是网络变压器共模抑制比?120dB与60dB的共模抑制比区别大吗?
  20. 人工智能常用评估指标

热门文章

  1. servlet使用监听器统计网站在线人数
  2. Python快速入门 满满都是干货!
  3. 2G、3G要退出历史舞台了?为何3G比2G淘汰更快?
  4. 软件测试常用的工具都在这里了
  5. 详解爬电距离和电气间隙
  6. hdu 5454 Excited Database(线段树)
  7. 【diannaoxitong】查看路由器ADSL帐号密码方法
  8. 使用vscode pull拉取报错: [rejected] (would clobber existing tag)
  9. Postman学习_Sinno_Song_新浪博客
  10. ios获取所有相册的视频并播放