繁体   English   中英

为什么>在Unix中使用Java执行curl命令时>>发生变化

[英]why > is getting changed &gt in Unix while executing curl command using Java

我有一个要求,我需要将AEM / CQ页面属性转换为XML并下载到服务器上的语言环境存储中。 我已经将页面属性转换为XML,并且要下载,我使用curl命令并通过java Runtime.getRuntime()。exec(command)执行该命令。 它可以在Windows上运行,但在Unix上会产生问题。 下面是我的命令“ curl -u id:password http:// serveraddress:4502 / content / mypage.xml > mypage.xml”在服务器上运行我的程序时,出现以下错误的Unix框

> <head><title>404 Resource at
> '/content/mypage.xml&gt;mypage.xml>mypage.xml' not found: No resource
> found</title></head> <body> <h1>Resource at
> '//content/mypage.xml&gt;mypage.xml&gt;mypage.xml' not found: No
> resource found</h1> <p>Cannot serve request to
> /content/mypage.xml&gt;mypage.xml&gt;mypage.xml on this server</p>
> <address>Apache Sling</address> </body>

“>”将转换为&gt。 有什么想法请分享。

重定向>由shell评估。

这样就可以用Java执行

bash -c "curl -u id:password http://serveraddress:4502/content/mypage.xml>mypage.xml"

或使用ProcessBuilder无需任何重定向即可捕获curl的输出,并用Java写入mypage.xml

您可以尝试curl -u id:password http://serveraddress:4502/content/mypage.xml -o mypage.xml

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM