0

I am using:

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

when argLine

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

with 2 params ,and i use &amp; escape & symbols

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

the style param lost

In short,i want run

<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 update

Yes,Windows system

I change code to

<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>

run ant

only open

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

I change "&amp;%3b" to "&amp;"

also only open

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

But in cmd, i use

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

can open http://127.0.0.1/product/findSameStyleSku.json?skuId=305&style=120662

feilong
  • 721
  • 1
  • 12
  • 25

1 Answers1

1

Not exactly understanding what it's trying to open. Is it literally trying to open a URL with ***?skuId=305, or are you trying to say it's trying to open the URL you gave it up to, but not including the semicolon?

If you are saying that it is leaving off the last part of your URL, you should understand that semicolons cannot be part of the actual URL you're sending. They're reserved and must be specially encoded.

Make sure that semicolon is even suppose to be there. When you do a GET request, you have the basic URL, and then after that URL a question mark. After that, you have a series of parameters you're passing to the URL with each parameter separated by ampersands. In your case, it looks like you want to send a request to URL:

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

With the following two parameters:

  • skuId = 305
  • style = 120662

So, it looks like the semicolon is bogus. Otherwise, you're passing the parameter ;style and not style. And, that doesn't seem it would be correct.

If you've determined that the semicolon is really suppose to be there, try replacing the semicolon in the URL with %3b:

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

Response

,i'm sorry ,it does't Work correctly,I updated my question – feeling

Unfortunately, since this is on a Windows machine, and is something running locally on your machine, I can't run a test myself.

However, according to the first part of your post, you are attempting to run the following command:

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

Later in your post, you say you want to run:

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

The first certainly won't work from the command line. Does the second one?

I've done a few tests on my current computer using this:

<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>

This is the curl command which fetches the URL. This URL is also uses a GET method, so it also has a question mark and some asterisks in the URL. This works for me.

Try switching from <arg line='start' '' 'http://...> to using <arg line> and see if that helps:

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

Community
  • 1
  • 1
David W.
  • 105,218
  • 39
  • 216
  • 337
  • I want to express the meaning behind, but,when i execute ,Ant build failed,warn: The reference to entity "amp" must end with the ';' delimiter. – feilong May 18 '12 at 09:08
  • @feilong -- Sorry, I mistyped it. I changed `&amp` to `&`. The answer should now be correct. – David W. May 18 '12 at 20:41
  • 1
    @feilong See the response added to my original answer – David W. May 22 '12 at 14:35
  • @feilong I'm sure I must be missing something here. Have you tried running ant via `--verbose` or the `--debug` switch to see if this gives you any more information. Can you set a property with the URL and then print out that URL? – David W. May 24 '12 at 02:33