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"

    评论

报告相同问题?

悬赏问题

  • ¥15 帮我写一个c++工程
  • ¥30 Eclipse官网打不开,官网首页进不去,显示无法访问此页面,求解决方法
  • ¥15 关于smbclient 库的使用
  • ¥15 微信小程序协议怎么写
  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教