Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I escape double-quotes in ant?

Tags:

exec

ant

I need to exec the following command from ant, but I can't figure out how to escape the double-quotes:

tasklist /FI "IMAGENAME eq java.exe" /FI "MEMUSAGE gt 50000" 
like image 416
sachin Avatar asked Sep 12 '11 13:09

sachin


People also ask

How do you escape a double quote?

If you need to use the double quote inside the string, you can use the backslash character. Notice how the backslash in the second line is used to escape the double quote characters. And the single quote can be used without a backslash.

How do you escape a double quote in query string?

Double Quotes inside verbatim strings can be escaped by using 2 sequential double quotes "" to represent one double quote " in the resulting string. var str = @"""I don't think so,"" he said.

How do you escape a quote from a string?

You can put a backslash character followed by a quote ( \" or \' ). This is called an escape sequence and Python will remove the backslash, and put just the quote in the string. Here is an example. The backslashes protect the quotes, but are not printed.

How do you escape a double quote in XML?

To allow attribute values to contain both single and double quotes, the apostrophe or single-quote character (') may be represented as "'", and the double-quote character (") as """. Show activity on this post. A double quote character ( " ) can be escaped as " , but here's the rest of the story...


2 Answers

Ant script is xml. So in xml, here is the rule.

For > use >

For < use &lt;

For “ use &quot;

For & use &amp;

For ‘ use &apos;

Notice! ";"

Reference:

http://www.jguru.com/faq/view.jsp?EID=721755

like image 22
user890054 Avatar answered Sep 21 '22 20:09

user890054


Ant uses XML, so you can use the normal XML entities like &quot;:

tasklist /FI &quot;IMAGENAME eq java.exe&quot; /FI &quot;MEMUSAGE gt 50000&quot; 
like image 113
Michael Mrozek Avatar answered Sep 21 '22 20:09

Michael Mrozek