node.js - 向子进程发送快捷键
我的程序生成“ssh”作为子进程,连接到服务器,然后能够写入流并读取其输出。
这一切都很好。当我将“ls”写入进程流时,我会得到文件列表。
但现在,我想发送此进程的快捷键,以便我可以中止 ssh 会话中正在运行的进程。
我知道这也可以通过流来完成,但是我在哪里可以阅读有关我必须发送给进程以使其理解我的快捷键的内容?
感谢您的帮助!
My program spawns "ssh" as a child process, conntects to a server and is then able to write to the stream and read its output.
This all works fine. When I write "ls" to the process stream I get a list of the files.
But now, I want send key shortcuts to this process, so that I can abort the running process in the ssh session.
I know this can also be done through the stream, but where can I read about WHAT I must send to the process to make it understand my key shortcuts?
Thanks for any help!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
对于正常的 ssh 会话,在换行符后发送“~”是控制 ssh 程序本身的转义字符。例如“~”。将关闭连接。
在 联机帮助页 上搜索“波浪号”。
更新:
在重新阅读您的问题时,我认为您可能希望将 Ctrl-* 发送到 ssh 会话中运行的远程进程,而不是与 ssh 进程本身对话。您可能只能发送 Ctrl 键生成的 ASCII 序列:
Ctrl-C 会变成 ASCII 字符 0x03。这来自古代的哑终端。有关 ASCII 控制序列的更多信息。
With a normal ssh session, sending '~' after a newline is the escape character to control the ssh program itself. For example '~.' will close the connection.
Search for 'tilde' on the manpage.
Update:
On re-reading your question, I think you are probably wanting to send Ctrl-* to the remote process running in the ssh session rather than talking to the ssh process itself. You might just be able to send the ASCII sequence that the Ctrl key would generate:
ASCII character 0x03 is what Ctrl-C becomes. This is from the ancient days of dumb terminals. More about ASCII control sequences.