すべてはうまくコマンドラインで動作しますが、私がJavaに必要なものを翻訳すると、受信プロセスはstdin上で何も取得しません。sshのstdinにJavaを書き込む方法は?
は、ここで私が持っているものです。
private void deployWarFile(File warFile, String instanceId) throws IOException, InterruptedException {
Runtime runtime = Runtime.getRuntime();
// FIXME(nyap): Use Jsch.
Process deployWarFile = runtime.exec(new String[]{
"ssh",
"gateway",
"/path/to/count-the-bytes"});
OutputStream deployWarFileStdin = deployWarFile.getOutputStream();
InputStream deployWarFileStdout = new BufferedInputStream(deployWarFile.getInputStream());
InputStream warFileInputStream = new FileInputStream(warFile);
IOUtils.copy(warFileInputStream, deployWarFileStdin);
IOUtils.copy(deployWarFileStdout, System.out);
warFileInputStream.close();
deployWarFileStdout.close();
deployWarFileStdin.close();
int status = deployWarFile.waitFor();
System.out.println("************ Deployed with status " + status + " file handles. ************");
}
スクリプト「カウントバイト」単純です:
#!/bin/bash
echo "************ counting stdin bytes ************"
wc -c
echo "************ counted stdin bytes ************"
出力機能は「トイレ-c」行でハングことを示しています - それは 'countd stdin bytes'行には決して行きません。
何が起こっているのですか? Jschの助けを借りたいですか?
IOCopyを使用すると、どの値が返されますか? – Snicolas
copyLarge()を使用するようにコードを変更しました。それは返す30054046。 –