xshell script api

Xshell支持使用VB,JS,Python脚本去启动自动化任务。这里介绍一下xshell提供的API,并且提供一个python包xsh提高开发效率。

xsh.Seesion

The following functions and variables can be used in Xshell sessions. To use these functions and variables, execute them together with xsh.Session. For example, to use ‘Sleep()’ function, use ‘xsh.Session.Sleep(1000)’.

Return Value Function Parameter Description
Void Open(LPCTSTR lpszSession) lpszSession A character string of an Xshell session path or URL format of Xshell. Open a new session or URL. To open a session, place /s option in front of a character string. Ex.) To open the A.xsh session, use ‘/s $PATH/A.xsh’.
Void Close() Close the currently connected session.
Void Sleep(long timeout) Timeout Milisecond unit time value. Make Xshell wait for the designated time.
Void LogFilePath(LPCTSTR lpszNewFilePath) lpszNewFilePath File name including path Designate log file.
void StartLog() Start logging for a session. Log is designated with a path specified in LogFilePath(). If a log file path is not designated, the default path is used.
void StopLog() Stop logging.
Name Type Description
Connected BOOL Check whether current session is connected.
LocalAddress BSTR Retrieve the local address.
Path BSTR Retrieve the current session file path.
RemoteAddress BSTR Retrieve the remote address.
RemotePort long Retrieve the remote port.
Logging BOOL Check whether current session is recording log file.
LogFilePath BSTR Save as a log file.

xsh.Screen

The following functions and variables can be used when handling of the Xshell terminal screen. To use these functions and variables, execute them together with the xsh.Screen. For example, to use ‘Clear()’ function, use ‘xsh.Session.Clear()’.

Return Value Function Parameter Description
void Clear() Clear terminal screen.
void Send(LPCTSTR lpszStrToSend) lpszStrToSend Character string to send Send message to terminal.
BSTR Get(long nBegRow, long nBegCol, long nEndRow, long nEndCol) nBegRow Terminal row starting position nBegCol Terminal column starting position nEndRow Terminal row ending position nEndCol Terminal column ending position Read the character string in the specified terminal section and return the value.
void WaitForString(LPCTSTR lpszString) lpszString Character string to be displayed on the terminal. Wait for message.
Long WaitForStrings(VARIANT FAR* strArray, long nTimeout) strArray Character string to be displayed on the terminal nTimeout Wait time millisecond value Return Value The number of found strings. Wait for message until timeout.
Name Type Description
CurrentColumn long Return the current column.
CurrentRow long Return the current row.
Columns long Retrieve the total columns same as terminal width.
Rows long Retrieves the total row same as terminal lines
Synchronous BOOL Set screen synchronization (True means synchronize and false means do not synchronize)

xsh.Dialog

You can use this to manipulate the Xshell terminal screen. To use the following function and variable, execute it with xsh.Dialog. For example, if you want to use the MsgBox() function, append xsh.Dialog.MsgBox() in the front like this: xsh.Dialog.MsgBox().

Return Value Function Parameter Description
Long MsgBox(LPCTSTR lpszMsg) LpszMsg:
String you want to send.
Open a message box.
string Prompt(LPCTSTR lpszMessage, LPCTSTR lpszTitle, LPCTSTR lpszDefault, BOOL bHidden) lpszMessage:
The string to be displayed in the Prompt Dialog Box
lpszTitle:
The string to be displayed in the title bar of the Prompt Dialog Box
lpszDefault:
Initial default string of Prompt Dialog Box input box
bHidden:
If set to True, input will be hidden (e.g. *****)
Description:
Returns user’s input from Prompt Dialog Box
Return Values:
User’s input from Prompt Dialog Box
int MessageBox(LPCTSTR lpszMessage, LPCTSTR lpszTitle, int nType) lpszMessage:
The string to be displayed in the Message Box
lpszTitle:
The string to be displayed in the title bar of the Message Box
nType:
Dictates button types. Refer to the table below
Description:
Displays a message box with a variety of buttons and return values depending on the user’s button selection
Return Values:
Refer to the nType parameter description below
nType Button Return Value
0 OK 1
1 OK / Cancel 1 / 2
2 Abort / Retry / Ignore 3 / 4 / 5
3 Yes / No / Cancel 6 / 7 / 2
4 Yes / No 6 / 7
5 Retry / Cancel 4 / 2
6 Cancel / TryAgain / Continue 2 / 10 / 11

xshell官网原文:https://netsarang.atlassian.net/wiki/spaces/ENSUP/pages/419957269/Script+API

由于直接通过这些API去开发Xshell的python脚本,可能由于拼写等原因,不能顺畅的开发,所以我将官方的API打包,用python写了一个同名的xsh包,API接口和官方完全一致,并提供详细的注释,通过这个包,可以大大提供开发效率,在使用时,也仅仅只需要注释掉导入包的语句即可。

项目地址:https://github.com/AZMDDY/xshapi

xshell 执行脚本API介绍(附带xsh的python包)相关推荐

  1. MicroFocus 监控工具 SiteScope 搭配Task scheduler在远程Windows上执行脚本

    文章目录 SiteScope介绍 配置步骤 1.在远程被监控Windows上准备工作 2.SiteScope端配置 3.设置SiteScope 总结 SiteScope介绍 SiteScope 是HP ...

  2. Xshell 执行python脚本

    XShell支持使用VB,JS,Python脚本去启动自动化任务.这里介绍如何写Xshell的Python脚本. 首先要在脚本中定义一个Main()函数,Xshell会调用这个函数,也就是程序的入口. ...

  3. Ansible介绍、安装、远程执行命令、拷贝文件或者目录、远程执行脚本

    Ansible介绍 不需要安装客户端,通过sshd去通信 基于模块工作,模块可以由任何语言开发 不仅支持命令行使用模块,也支持编写yaml格式的playbook,易于编写和阅读 安装十分简单,cent ...

  4. xshell执行sql脚本

    xshell执行sql脚本 上传文件见上一篇博客 1.通过xshell连接mysql 2.将服务器上目的目录中的sql文件导入 注意:一定要先选择一个数据库 3.此时test数据库中已经多了一张&qu ...

  5. ansible介绍、安装、远程执行命令、拷贝文件或目录、远程执行脚本、管理任务计划、安装包和管理服务、playbook、变量、循环、条件判断、handlers、安装nginx、管理配置文件

    24.15 ansible介绍 ansible是新出现的自动化运维工具,基于Python开发,集合了众多运维工具(puppet.cfengine.chef.func.fabric)的优点,实现了批量系 ...

  6. xshell自动化脚本

    xshell具有脚本功能,可以实现很多自动化的操作. 从xshell的官方手册,可以知道xshell的脚本分为3类: xsh.Session 下面的函数或变量在xshell会话中使用,使用的时候要指定 ...

  7. elasticsearch 6.x (五) 单一文档 API 介绍和使用 update和delete API

    大家好,我是烤鸭: 今天分享的是官网6.x    单一文档(Single document APIs)APIs. 本文这是部分翻译,如果想看全部的,还是建议阅读官方api.链接: https://ww ...

  8. 有生之年转ta系列4pc手机图形api介绍

    本文内容来自 [技术美术百人计划]图形 1.4 PC手机图形API介绍 观后记录 美术岗位代码或者算法一类的问题可能不太懂 本文仅用来记录学习,如果有不对的请指出谢谢 图形部分 第一章 4纹理基础 前 ...

  9. Python+Selenium 自动化测试 2. Webdriver API介绍

    目录 一 Webdriver介绍 二 webdriver实现的原理 三  API介绍 Webdriver 元素的查找的八种方式 find_element_by_id()  源码 find_elemen ...

  10. (转)ASP.NET 脚本语言介绍

    (转自) http://www.72e.net/support/docread-99.aspx Asp.Net 脚本语言介绍 查看次数:117017   更新时间:2005-11-27        ...

最新文章

  1. Cell子刊:16s分析之FishTaco分析
  2. mysql8.0怎么导入数据_MySQL8.0导入数据
  3. java 传递intent_java – 如何将泛型类作为param传递给Intent构造函数
  4. 中海达手部链接电脑安装软件_山东水文局:较大含沙量条件下中海达ADCP外接测深仪测流系统试验成功...
  5. SpringCloud 从菜鸟到大牛之三 服务拆分 理论
  6. 【Linux】awk处理变量
  7. jvm诊断之学习jcmd入门
  8. Leetcode 5067.统计只含单一字母的子串
  9. mysql补0操作有什么意义?
  10. 查看Anaconda内置的Python版本的方法
  11. HttpServletRequest请求转发
  12. 用计算机算出你的姓名,生辰八字在线计算器,怎么看自己生辰八字
  13. ATF(Arm Trusted Firmware)/TF-A Chapter 03 Chain of Trust (CoT)
  14. 关于Chrome的谷歌翻译和IDEA中的Translation翻译插件无法使用的解决方法
  15. Excel快捷键大全 Excel2013/2010/2007/2003常用快捷键大全【转】
  16. java雷霆战机项目收获_java实习项目_雷霆战机
  17. 计算机单位厘米 像素,300dpi的dpi是多少?是像素/英寸吗?还是像素/厘米?
  18. CoolPad 8190工程模式
  19. 【MATLAB】求Taylor展开式
  20. 是不是每个软件测试人员都有一份跟我差不多的心酸历程?

热门文章

  1. android xcl charts,我写的Android图表库XCL-Charts,整理好现在开源了!!!
  2. php 模板对象,php面向对象--PHP模板 ppt
  3. java对网络图片进行签名
  4. 干净的国内系统镜像源
  5. iOS辅助功能Accessibility浅析
  6. 秒杀:超卖问题(图解+秒懂+史上最全)
  7. Granted QOS different to Requested QOS
  8. vue打开新html,vue在新窗口打开页面的方法
  9. *TEST 11 for NOIP 再次爆炸 (100-300)-----(( ! ))
  10. Linux基础3-实用进阶