File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Soft Skills: The software developer's life manual this week in the Jobs Discussion forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Rather simple ant question

 
Neha Gap
Greenhorn
Posts: 29
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I want to know how to use the special characters (like < ) in an ant build file.

I'm trying to create a target in my ant file to execute a script in mysql. Since mysql has no options for input file, on the command prompt, it can be done using the < filename.sql option. However, putting the < character in the arg section of exec task in an ant file gives errors.

Any help would be really appreciated.
Thanks!
Neha.
 
Tim Holloway
Saloon Keeper
Pie
Posts: 17616
38
Android Eclipse IDE Linux
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK, there's several issues here.

First, an Ant build.xml file is (suprise!) an XML file. The < > " & and ' characters cannot be used directly, since they all have meaning as XML lexical elements, so instead you either have to use a CDATA or an entity (&lt; &gt; &quot; &amp; and &apos .

But that's not enough. The '<' character has no special meaning to Ant as regards I/O piping and redirection - that functionality is provided by the user's command shell. SO what you really need isn't a way to code a redirection, but rather a specific redirection directive.

Example:
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic