[GH-ISSUE #1662] 有脚本的示例说明吗 #967

Closed
opened 2026-02-27 00:01:43 +03:00 by kerem · 4 comments
Owner

Originally created by @zzhzero on GitHub (Apr 20, 2020).
Original GitHub issue: https://github.com/electerm/electerm/issues/1662

比如条件语句 检测回显之类的

Originally created by @zzhzero on GitHub (Apr 20, 2020). Original GitHub issue: https://github.com/electerm/electerm/issues/1662 比如条件语句 检测回显之类的
kerem closed this issue 2026-02-27 00:01:43 +03:00
Author
Owner

@zxdong262 commented on GitHub (Apr 20, 2020):

是说登陆后运行的脚本吗?那就是sh脚本(对于linux服务器而言)

<!-- gh-comment-id:616524148 --> @zxdong262 commented on GitHub (Apr 20, 2020): 是说登陆后运行的脚本吗?那就是sh脚本(对于linux服务器而言)
Author
Owner

@ViCrack commented on GitHub (Dec 30, 2021):

@zxdong262 我搜了一下好像只有比较简单的登陆后运行的脚本,自动化处理的能力不强。
是否考虑以后增加自动化脚本的功能
就像SecureCRTlogon script (支持python)
一些传递过去的命令参数值是通过编程的方式获得,比如用于登录2FA认证
图片

<!-- gh-comment-id:1002850008 --> @ViCrack commented on GitHub (Dec 30, 2021): @zxdong262 我搜了一下好像只有比较简单的登陆后运行的脚本,自动化处理的能力不强。 是否考虑以后增加自动化脚本的功能 就像**SecureCRT**的**logon script** (支持python) 一些传递过去的命令参数值是通过编程的方式获得,比如用于登录2FA认证 ![图片](https://user-images.githubusercontent.com/18179821/147717394-77fd0c81-9e9e-4bfe-8642-a519ec866a0a.png)
Author
Owner

@zxdong262 commented on GitHub (Dec 30, 2021):

方便详细说说吗,这个自动脚本是怎么个工作流程?

<!-- gh-comment-id:1002855252 --> @zxdong262 commented on GitHub (Dec 30, 2021): 方便详细说说吗,这个自动脚本是怎么个工作流程?
Author
Owner

@ViCrack commented on GitHub (Dec 30, 2021):

以SecureCRT为例,它会提供一些内置的扩展Api给python或js等脚本来使用,当连接到ssh上,比如脚本中调用了Send则会发送命令到服务端,用FileTransfer可以传输文件,调用了WaitForString则是等待服务端的回显输出,效果上看有点像expect的命令脚本,实现上可能是采取了某种插件扩展的机制,启动时加载脚本,注入crt的全局对象,可编程实现自动化操作。

def main():
    crt.Screen.Synchronous = True
    crt.Screen.Send("echo 'password' | sudo -S ls\r")
    crt.Screen.Send("sudo su - username\r")
    crt.Screen.Send("clear\r")

    crt.Screen.Synchronous = False
main()

https://documentation.help/SecureCRT/Application_Object.htm
https://www.vandyke.com/products/securecrt/scripts.html

<!-- gh-comment-id:1002865342 --> @ViCrack commented on GitHub (Dec 30, 2021): 以SecureCRT为例,它会提供一些内置的扩展Api给python或js等脚本来使用,当连接到ssh上,比如脚本中调用了`Send`则会发送命令到服务端,用`FileTransfer`可以传输文件,调用了`WaitForString`则是等待服务端的回显输出,效果上看有点像expect的命令脚本,实现上可能是采取了某种插件扩展的机制,启动时加载脚本,注入crt的全局对象,可编程实现自动化操作。 ```python def main(): crt.Screen.Synchronous = True crt.Screen.Send("echo 'password' | sudo -S ls\r") crt.Screen.Send("sudo su - username\r") crt.Screen.Send("clear\r") crt.Screen.Synchronous = False main() ``` [https://documentation.help/SecureCRT/Application_Object.htm](https://documentation.help/SecureCRT/Application_Object.htm) [https://www.vandyke.com/products/securecrt/scripts.html](https://www.vandyke.com/products/securecrt/scripts.html)
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/electerm#967
No description provided.