ZhiBing's blog(码上看世界) ZhiBing's blog(码上看世界)
首页
  • Linux工具链

    • shell命令
  • 构建

    • CMake
    • Makefile
  • 版本管理

    • Git
    • Github
  • IDE及工具

    • vscode
    • CLion
  • 设计模式

    • 设计原则
  • 编程语言

    • C++
    • Go
    • Python
    • Shell
  • 调试

    • gdb
  • 开发者测试

    • gtest
  • 系统支撑

    • 操作系统
  • 性能优化

    • 编译优化选项
    • perf
    • valgrind
  • 容器

    • Docker
  • 微服务

    • Rancher
  • 其他
  • 随笔
  • 友情链接
收藏
  • 分类
  • 标签
  • 归档
关于
GitHub (opens new window)

ZhiBing Zheng

时间会回答成长
首页
  • Linux工具链

    • shell命令
  • 构建

    • CMake
    • Makefile
  • 版本管理

    • Git
    • Github
  • IDE及工具

    • vscode
    • CLion
  • 设计模式

    • 设计原则
  • 编程语言

    • C++
    • Go
    • Python
    • Shell
  • 调试

    • gdb
  • 开发者测试

    • gtest
  • 系统支撑

    • 操作系统
  • 性能优化

    • 编译优化选项
    • perf
    • valgrind
  • 容器

    • Docker
  • 微服务

    • Rancher
  • 其他
  • 随笔
  • 友情链接
收藏
  • 分类
  • 标签
  • 归档
关于
GitHub (opens new window)
  • 其他

    • 安装 mariadb 数据库
    • 创建自己的jekyll主题
    • 搭建私有云盘
    • 搭建Git服务器
    • Linux开放端口
    • 内核链表
    • 树莓派4安装k3d
    • 树莓派4安装k3s
    • 树莓派4更换镜像源
    • 树莓派4设置静态IP
    • 树莓派安装docker
    • 远程连接mariadb数据库
    • Latex
    • mac安装jekyll
    • docker + nextcloud 搭建私有云(Linux)
    • nginx使用自签名SSL证书
    • raspbian-buster-lite安装桌面
    • ubuntu18.04 + jekyll 搭建个人博客站
    • Ubuntu刷新DNS缓存
    • wsl后台运行程序
    • xshell script api
      • xsh.Seesion
      • xsh.Screen
      • xsh.Dialog
    • HPE gen10 plus 安装telsa P4驱动
    • HPE gen10 plus 安装ESXI 7
    • ESXI 7安装黑群晖
    • ESXI 7安装win10
  • 随笔

  • 专题

  • 友情链接
  • 更多
  • 其他
zhengzhibing
2022-06-16
目录

xshell script api

# xshell script api

Xshell 支持使用 VB,JS,Python 脚本去启动自动化任务。这里介绍一下 xshell 提供的 API。

# 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 (opens new window)

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

项目地址:https://github.com/AZMDDY/xshapi (opens new window)

#xshell
上次更新: 2022/06/17, 07:22:19
wsl后台运行程序
HPE gen10 plus 安装telsa P4驱动

← wsl后台运行程序 HPE gen10 plus 安装telsa P4驱动→

最近更新
01
HPE gen10 plus 安装ESXI 7
06-12
02
ESXI 7安装黑群晖
06-12
03
ESXI 7安装win10
06-12
更多文章>
Theme by Vdoing | Copyright © 2022-2024 ZhBing Zheng | 粤ICP备2022062743号
  • 跟随系统
  • 浅色模式
  • 深色模式
  • 阅读模式