为什么在使用JSch时看到乱码? [英] Why do I see scrabbled output when using JSch?
问题描述
我正在尝试使用 JSch
。我试过的例子是 here
虽然我可以连接输出是奇怪的。
我得到以下内容:
I am trying to use JSch
. I tried the example here
Although I can connect the output is weird.
I get the following:
Last login: Thu Jan 31 19:44:25 2013 from 10.2.251.77
[1mcli:~ # [m
如果我做例如一个 ls
我得到:
And if I do e.g. an ls
I get:
[0m[01;34m.InstallAnywhere[0m [00m.bash_history [00m.bash_profile[0m
[01;34mbin[0m [00msles11-patched[0m
[01;34m.kbd[0m [00mindex.html[0m [00mtest.sql[0m
[00m.viminfo[0m [00;31mipvsadm-1.26-1.src.rpm[0m
[m[1mcli:~ # [m
这些是目录内容,但为什么会这样显示?
我从Eclipse中运行这个,这就是我请参阅Eclipse输出。如果我从Windows CMD
中运行它,它会卡住
These are the directory contents but why are they displayed like that?
I am running in this from Eclipse and this is what I see in Eclipse output. If I run this from Windows CMD
it stucks
更新:
我注意到,如果我连接到不同的linux输出是好的!
只有我连接到一个特定的linux安装我看到这些奇怪的字符!任何想法是什么导致这个?
Update:
I noticed that if I connect to a different linux the output is fine!
Only if I connect to a specific linux installation I see these weird characters! Any idea what is causing this?
Update2:
按照@PeterMmm的链接,我做了 printfäöü XXD
。 坏和好的一个给出:
0000000:e4f6 fc
我也做过
。
在不好的情况下:
Update2:
Following the link of @PeterMmm I did printf "äöü" | xxd
. Both the "bad" and good one give:
0000000: e4f6 fc
I also did locale
.
In the "bad" case:
# locale
LANG=POSIX
LC_CTYPE=en_US.UTF-8
LC_NUMERIC="POSIX"
LC_TIME="POSIX"
LC_COLLATE="POSIX"
LC_MONETARY="POSIX"
LC_MESSAGES="POSIX"
LC_PAPER="POSIX"
LC_NAME="POSIX"
LC_ADDRESS="POSIX"
LC_TELEPHONE="POSIX"
LC_MEASUREMENT="POSIX"
LC_IDENTIFICATION="POSIX"
LC_ALL=
在良好的系统中:
LANG=POSIX
LC_CTYPE=en_US.UTF-8
LC_NUMERIC="POSIX"
LC_TIME="POSIX"
LC_COLLATE="POSIX"
LC_MONETARY="POSIX"
LC_MESSAGES="POSIX"
LC_PAPER="POSIX"
LC_NAME="POSIX"
LC_ADDRESS="POSIX"
LC_TELEPHONE="POSIX"
LC_MEASUREMENT="POSIX"
LC_IDENTIFICATION="POSIX"
LC_ALL=
配置似乎是一样的。那么可能是什么原因造成的?
Configuration seems to be the same. So what could be causing this?
推荐答案
请检查
有趣的Shell输出:[01; 32mtestfile.txt [00m而不是testfile.txt
((ChannelShell) channel).setPtyType("dumb");
做窍门
这篇关于为什么在使用JSch时看到乱码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!