私は現在、JSCHを使用して、シェルのチャンネルからと読み書きするためにパイプで連結された入力/出力ストリームプリンシペを使用しています。
問題:私はjQueryの端末にシェルの応答を転送するとき、私は私のjQueryの端末に奇妙な文字を取得しています。
私はこの問題を解決するためにさまざまな方法でパイプで連結された入力ストリームの読み取りを試みました:
1をお試しください:
private synchronized String readResponse() throws IOException {
byte[] array = new byte[pin.available()];
pin.read(array);
return new String(array, Charset.forName("UTF-8"));
}
2をお試しください:
private synchronized String readResponse() throws IOException {
final StringBuilder s = new StringBuilder();
while(pin.available() > 0) {
s.append((char) pin.read());
}
return s.toString();
}
悲しいことに、この問題はまだ残っています。缶誰の助け私?
アップデート:私はちょうど私が私のJava出力コンソールで同じ文字列を印刷するとき、ことが判明、それが動作します。
Update 2: I've imported the unix_formatting.js file and it's almost fixed. The thing with this file is that it has limited support for unix escape codes. Link to js: https://unpkg.com/[email protected]/js/unix_formatting.js
How can I fix this problem in jQuery terminal?
The problem you're having is that by default jQuery Terminal don't support ANSI escape codes but you can enable basic support by including unix_formatting.js file, the file is created using UMD so you can import it and have it in Webpack or Rollup bundle or include it using script tag:
Simplest is using unpkg.com:
<script src="https://unpkg.com/jquery.terminal/js/unix_formatting.js"></script>
you can also use same CDN as for main files (jsDeliver or cdnJS)
I think that cdn.rawgit.com
will work until October 2019 so it's better to not use that one.
しかし、jQueryのターミナルがそうすることができない一つのことは、あなたがブラウザでターミナルで対話型シェルコマンドを表示することはできないだろうということです。ライブラリはunix_formattingファイル内でシェルコマンドの基本的なサポートとJavaScriptで独自のコマンドを記述するために作成されました。
ブラウザで完全なUNIX端子を持つようにしたい場合は、より良い選択になりますxterm.js本当のttyです。あなたは、おそらくあなたは、Javaを実行していることができれば、サーバーを実行することができた場合、xterm.jsはずっと良くなります。あなたも実行することができますvi
またはemacs -nw
それと。