我試圖從Java到一臺服務器進行SSH連接並運行多個命令。命令似乎工作正常,但我沒有得到我想要的Java結果。sshj exec不按我期望的方式顯示結果
這裏是我的代碼片段
final Command cmd = session.exec("cd /app/t/backo/bin && ls -all && pwd && . setDBLApp && sudo -E -u deploy ./runDBLApp && sudo -E -u deploy ./nightlyDBL -type host ");
System.out.println(IOUtils.readFully(cmd.getInputStream()).toString());
cmd.join(30, TimeUnit.SECONDS);
System.out.println("\n** exit status: " + cmd.getExitStatus());
這是我看到的輸出。我認爲它與LocalWindow尺寸有關,但我無法弄清楚如何解決它。這只是發生(或似乎)當我使用ssh命令,將有大量的屏幕輸出
的這是一個小片段,我得到100行左右的這個
14:56:48.957 [reader] INFO n.s.s.c.c.direct.SessionChannel - Received window adjustment for 2097152 bytes
14:56:48.957 [reader] DEBUG n.s.s.c.channel.Window$Remote - Increasing by 2097152 up to 2097152
14:56:48.957 [reader] DEBUG net.schmizz.concurrent.Promise - Setting <<chan#0/chanreq for exec>> to `SOME`
14:56:48.963 [reader] DEBUG n.s.s.c.channel.Window$Local - Consuming by 4096 down to 2093056
14:56:48.964 [reader] DEBUG n.s.s.c.channel.Window$Local - Consuming by 1002 down to 2092054
14:56:48.964 [reader] DEBUG n.s.s.c.channel.Window$Local - Consuming by 23 down to 2092031
14:56:49.090 [reader] DEBUG n.s.s.c.channel.Window$Local - Consuming by 141 down to 2091890
14:56:49.120 [reader] DEBUG n.s.s.c.channel.Window$Local - Consuming by 267 down to 2091623
14:56:49.230 [reader] DEBUG n.s.s.c.channel.Window$Local - Consuming by 309 down to 2091314
14:56:49.531 [reader] DEBUG n.s.s.c.channel.Window$Local - Consuming by 308 down to 2091006
14:56:49.532 [reader] DEBUG n.s.s.c.channel.Window$Local - Consuming by 306 down to 2090700
我想看到的是什麼從ssh命令輸出的屏幕輸出可能很冗長