所以我有一個字符串,我想給exec,捲曲串...當它被exec'd它屠殺我的用戶代理字符串...的Runtime.exec()不表現爲預期
這裏是我exec'ing串...
/usr/bin/curl -L --no-keepalive --max-time 30 --connect-timeout 30 --insecure --max-redirs 10 --stderr /var/folders/+j/+jqu+V1eEoSalBbXTff74U+++TI/-Tmp-/output7756019899402490058.tmp --cookie-jar /var/folders/+j/+jqu+V1eEoSalBbXTff74U+++TI/-Tmp-/cookies4551380191209065239.tmp --user-agent "1 2 3 4 5" --dump-header /var/folders/+j/+jqu+V1eEoSalBbXTff74U+++TI/-Tmp-/headers159122813500476027.tmp http://test.com
下面是我用給exec它
Process pr = null;
Runtime run = Runtime.getRuntime();
try {
pr = run.exec(cmdline.split(" "));
A ret = f.f(pr);
pr.waitFor();
return ret;
} catch (Exception ex) {
throw new RuntimeException("Executing " + cmdline, ex);
} finally {
try {
// close all those bloody streams
pr.getErrorStream().close();
pr.getInputStream().close();
pr.getOutputStream().close();
} catch (IOException ex) {
Log.get().exception(Log.Level.Error, "Closing stream: ", ex);
}
}
這裏的代碼與用戶代理的Apache日誌搞砸...
192.168.1.105 - - [07/Feb/2012:20:59:38 -0500] "GET/HTTP/1.1" 200 6791 "-" "\"1"
預期的結果在Apache中應顯示完整的用戶代理(在這種情況下,1 2 3 4 5)
192.168.1.105 - - [07/Feb/2012:20:59:38 -0500] "GET/HTTP/1.1" 200 6791 "-" "1 2 3 4 5"
什麼期望輸出 – Woot4Moo 2012-02-08 02:07:49
我喜歡你的頭像... – ariefbayu 2012-02-08 02:09:23
應該是192.168.1.105 - - [07 /二月/ 2012:20:59:38 -0500] 「GET/HTTP/1.1」 200 6791「 - 「」1 2 3 4 5「 – MichaelICE 2012-02-08 02:09:37