1
Javaプログラムからrsync
を実行したかったのですが、私はこのJavaプログラムを実行するとjavaプログラムから "rsync"を実行する際のlink_statエラー
String cmd = "rsync -auv /rsrch1/rists/moonshot/data/foundation/FoundationMedicine/*.csv " + archive.getAbsolutePath();
System.out.println(cmd);
// capture stdout and stderr from running bash script
Process p = Runtime.getRuntime().exec(cmd);
String line;
BufferedReader in = new BufferedReader(new InputStreamReader(p.getInputStream()));
while ((line = in.readLine()) != null) {
System.out.println(line);
}
BufferedReader err = new BufferedReader(new InputStreamReader(p.getErrorStream()));
while ((line = err.readLine()) != null) {
System.out.println(line);
}
p.waitFor();
in.close();
err.close();
は、しかし、私はエラーを得た:ここにコードがある
rsync -auv /rsrch1/rists/moonshot/data/foundation/FoundationMedicine/*.csv /rsrch1/rists/moonshot/data/dev/foundation/validation/archive
sending incremental file list
sent 18 bytes received 12 bytes 60.00 bytes/sec
total size is 0 speedup is 0.00
rsync: link_stat "/rsrch1/rists/moonshot/data/foundation/FoundationMedicine/*.csv" failed: No such file or directory (2)
rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1039) [sender=3.0.6]
私が直接サーバー上の正確なコマンドrsync -auv /rsrch1/rists/moonshot/data/foundation/FoundationMedicine/*.csv /rsrch1/rists/moonshot/data/dev/foundation/validation/archive
はしかし、それだけで正常に動作することを実行したとき。
なぜJavaでは動作しないのか分かりません。
/rsrch1/rists/moonshot/data/foundation/FoundationMedicine/*.csvが存在することを確認してください。 >>そのようなファイルやディレクトリはありません – abkrim
@abkrim、はい。私はこのコマンドはサーバー上のコマンドラインで動作すると言ったように – Nasreddin
私は私のMac OS X上でteste。 "/rsrch1/rists/moonshot/data/foundation/FoundationMedicine/*.csv"が引用されている場合はrsyncは機能しません。 rsyncはそのパスを引用しています。例:rsync -auv "* .xml"〜/ borrar/not work。 rsync -auv * .xml〜/ borrar /はうまく動作します。 – abkrim