dongzhuo7291 2017-11-26 03:42 采纳率: 100%
浏览 250

从OpenSSH客户端删除字符

I'm writing an SSH server in Golang. Currently I have a server which can read and write from/to the client. When the client presses the delete key the server receives unicode character 13 (delete). I can rewrite the current line by sending all but the deleted character to the client. However, it only rewrites as many characters as I send. This means the last characters don't get re-written until new characters are entered. Does anyone know what the server needs to send in order for characters to be deleted from the client.

Client

Operating system: Ubuntu 16.04

Ssh version: 1.2.12

Bash version: 4.3

  • 写回答

1条回答 默认 最新

  • dqwh1203 2017-11-26 09:15
    关注

    The answer is send a space " ".

    But I suspect you are going about this in the wrong way. SSH is just a way to let a user access a terminal. It is not a command line processor. That's the job of Bash or whatever other command line the user has selected. Bash should be able to handle this type of logic as it's designed to talk to a terminal. Re-implementing bash in go-lang is a huge task and if that's what you want to do then good luck!

    To avoid these problems (and make lot less work for yourself) you should be using a Pseudo Terminal to talk to bash not a pipe. If you do so then I believe bash should correctly handle backspaces for you.

    You may also want to look at "Using Pseudo Terminals to Control Interactive Programs"

    评论

报告相同问题?

悬赏问题

  • ¥20 jupyter保存图像功能的实现
  • ¥15 在grasshopper里DrawViewportWires更改预览后,禁用电池仍然显示
  • ¥15 NAO机器人的录音程序保存问题
  • ¥15 C#读写EXCEL文件,不同编译
  • ¥15 MapReduce结果输出到HBase,一直连接不上MySQL
  • ¥15 扩散模型sd.webui使用时报错“Nonetype”
  • ¥15 stm32流水灯+呼吸灯+外部中断按键
  • ¥15 将二维数组,按照假设的规定,如0/1/0 == "4",把对应列位置写成一个字符并打印输出该字符
  • ¥15 NX MCD仿真与博途通讯不了啥情况
  • ¥15 win11家庭中文版安装docker遇到Hyper-V启用失败解决办法整理