所以我有一个字符串,我想给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