aspose file tools*
The moose likes Ant, Maven and Other Build Tools and the fly likes Escaping & in command prompt Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » Ant, Maven and Other Build Tools
Bookmark "Escaping & in command prompt" Watch "Escaping & in command prompt" New topic
Author

Escaping & in command prompt

anish do
Greenhorn

Joined: Mar 30, 2010
Posts: 3
Hi,
How to escape & in command prompt. The whole idea is to pass a URL as a command line argument. But that URL contains & symbols. So I am getting the following error.
"'pid' is not recognized as an internal or external command,
operable program or batch file."

See the below ant script
<target name="x" depends="y">
<java classname="${main-class}" fork="true" failonerror="yes">
<classpath>
<path refid="lib.classpath" />
<fileset dir="${z}" includes="**/*.jar" />
</classpath>
<arg value="${URL}" />
</java>
</target>

Thanks
Anish
Martijn Verburg
author
Bartender

Joined: Jun 24, 2003
Posts: 3274
    
    5

Which operating system are you using? I'd suggest googling "escape characters on command line <insert you OS here>"


Cheers, Martijn - Blog,
Twitter, PCGen, Ikasan, My The Well-Grounded Java Developer book!,
My start-up.
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Unix uses the "&" character to put jobs into the background; I don't know if DOS uses it or not.
anish do
Greenhorn

Joined: Mar 30, 2010
Posts: 3
Hi,
I am using windows XP. I can pass the url in double quotes. Thanks for your help. If you know any other ways to resolve this issue please let me know

Thanks
Anish
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Escaping & in command prompt