Remove of unwanted characters when I am using JSch to run command [duplicate]

随声附和 提交于 2019-11-28 13:02:00

These are ANSI escape codes that are normally interpreted by a terminal client to pretty print the output.

You get these, because you the JSch "shell" channel by default requests a pseudo terminal for the session. In general, its a bad idea to use a "shell" channel for automation.

But if you really have to for some reason, disable pseudo terminal by calling setPty:

channel.setPty(false);

But in 99% cases it's a bad idea. Trying to simulate a human is error prone. The human-interaction features of commands tend to change (get improved), what in turn will break your code, when the server gets updated.

You better ask new question about your ultimate goal (what do you want to use top for?), because you are likely on a wrong track.


Related questions:

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!