0

我在用:

<exec executable="cmd">
<arg line="${argLine}" />
</exec>

什么时候argLine

<property name="argLine" value="http://127.0.0.1:/product/findSameStyleSku.json?skuId=305&amp;style=120662"/>

有 2 个参数,我使用&amp;转义&符号

但只开放http://127.0.0.1/product/findSameStyleSku.json?skuId=305

参数style丢失

简而言之,我想跑步

<target name="111test"> 
    <exec executable="cmd" output="e:/test.txt">
        <arg line="/c start '' 'http://127.0.0.1/product/findSameStyleSku.json?skuId=305&amp;%3bstyle=120662'" />
    </exec>  
</target>

2012-05-23 更新

是的,Windows系统

我将代码更改为

<target name="111test">
    <exec executable="cmd" output="e:/test.txt">
        <arg value="/c" />
        <arg value="start" />
        <arg value="" />
        <arg value="http://127.0.0.1/product/findSameStyleSku.json?skuId=305&amp;%3bstyle=120662" />
    </exec>
</target>

运行蚂蚁

只开

http://127.0.0.1/product/findSameStyleSku.json?skuId=305

我把“ &amp;%3b”改成“ &amp;

也只开

http://127.0.0.1/product/findSameStyleSku.json?skuId=305

但是在cmd中,我使用

start "" "http://127.0.0.1/product/findSameStyleSku.json?skuId=305&style=120662"

可以打开http://127.0.0.1/product/findSameStyleSku.json?skuId=305&style=120662

4

1 回答 1

1

不完全理解它试图打开什么。它是真的试图用 . 打开一个 URL ***?skuId=305,还是你想说它试图打开你放弃的 URL,但不包括分号?

如果您说它省略了 URL 的最后一部分,您应该了解分号不能成为您发送的实际 URL 的一部分。它们是保留的,必须经过特殊编码。

确保分号甚至假设在那里。当您执行GET请求时,您将获得基本 URL,然后在该 URL 之后有一个问号。之后,您将有一系列参数传递给 URL,每个参数由 & 号分隔。在您的情况下,您似乎想向 URL 发送请求:

  • http://127.0.0.1:/product/findSameStyleSku.json

使用以下两个参数:

  • skuId=305
  • style=120662

所以,看起来分号是假的。否则,您传递的是参数;style而不是style. 而且,这似乎并不正确。

如果您确定分号确实存在,请尝试将 URL 中的分号替换为%3b

<property name="argLine" value="http://127.0.0.1:/product/findSameStyleSku.json?skuId=305&amp;%3bstyle=120662"/>

回复

,对不起,它不能正常工作,我更新了我的问题——感觉

不幸的是,由于这是在 Windows 机器上,并且是在您的机器上本地运行的东西,所以我自己无法运行测试。

但是,根据您帖子的第一部分,您正在尝试运行以下命令:

C> cmd http://127.0.0.1:/product/findSameStyleSku.json?skuId=305&amp;style=120662

稍后在您的帖子中,您说您想运行:

C> cmd /c start '' 'http://127.0.0.1/product/findSameStyleSku.json?skuId=305&amp;%3bstyle=120662'

第一个肯定不会从命令行工作。第二个有吗?

我已经使用这个在我当前的计算机上做了一些测试:

<property name="argLine"
    value="http://etzahaim.org/index.php?option=com_content&amp;task=blogcategory&amp;id=15&amp;Itemid=34"/>
<exec executable="curl">
    <arg value="${argLine}"/>
    <arg value="--include"/>
    <arg value="--output"/>
    <arg value="curl.out"/>
</exec>

这是curl获取 URL 的命令。该 URL 也是使用 GET 方法,因此 URL 中还有一个问号和一些星号。这对我有用。

尝试从使用切换<arg line='start' '' 'http://...>到使用<arg line>,看看是否有帮助:

<target name="111test"> 
    <exec executable="cmd" output="e:/test.txt">
        <arg value="/c"/>
        <arg value="start"/>
        <arg value=""/>
        <arg value="${argline}" />
</exec>

于 2012-05-17T13:58:24.190 回答