Browse Source

Add FAQ entries for io-redirection via < and > in <exec>.

Somebody else will have to provide Windows details, if necessary 8-)


git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@269385 13f79535-47bb-0310-9956-ffa450edef68
master
Stefan Bodewig 24 years ago
parent
commit
747f539937
2 changed files with 170 additions and 0 deletions
  1. +120
    -0
      webpage/docs/faq.html
  2. +50
    -0
      webpage/xdocs/faq.xml

+ 120
- 0
webpage/docs/faq.html View File

@@ -147,6 +147,13 @@
<li><a href="#jikes-switches">
How can I use Jikes specific command line
switches?
</a></li>
<li><a href="#shell-redirect-1">
How do I include a &lt; character in my command line arguments?
</a></li>
<li><a href="#shell-redirect-2">
How do I redirect standard input or standard output
in the <code>&lt;exec&gt;</code> task?
</a></li>
</ul>
</blockquote>
@@ -563,6 +570,119 @@
</blockquote>
</td></tr>
</table>
</a>
<a name="shell-redirect-1">
<table border="0" cellspacing="0" cellpadding="2" width="100%">
<tr><td bgcolor="#828DA6">
<font color="#ffffff" face="arial,helvetica,sanserif">
<strong>
How do I include a &lt; character in my command line arguments?
</strong>
</font>
</td></tr>
<tr><td>
<blockquote>
<p>The short answer is "Use <code>&amp;lt;</code>".</p>
<p>The long answer is, that this probably won't do what you
want anyway, see <a href="#shell-redirect-2">the next
section</a>.</p>
</blockquote>
</td></tr>
</table>
</a>
<a name="shell-redirect-2">
<table border="0" cellspacing="0" cellpadding="2" width="100%">
<tr><td bgcolor="#828DA6">
<font color="#ffffff" face="arial,helvetica,sanserif">
<strong>
How do I redirect standard input or standard output
in the <code>&lt;exec&gt;</code> task?
</strong>
</font>
</td></tr>
<tr><td>
<blockquote>
<p>Say you want to redirect the standard input stream of the
<code>cat</code> command to read from a file, something
like</p>
<div align="left">
<table cellspacing="4" cellpadding="0" border="0">
<tr>
<td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
<td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
<td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
</tr>
<tr>
<td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
<td bgcolor="#ffffff"><pre>
shell-prompt&gt; cat &lt; foo
</pre></td>
<td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
</tr>
<tr>
<td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
<td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
<td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
</tr>
</table>
</div>
<p>and try to translate it into</p>
<div align="left">
<table cellspacing="4" cellpadding="0" border="0">
<tr>
<td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
<td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
<td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
</tr>
<tr>
<td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
<td bgcolor="#ffffff"><pre>
&lt;exec executable=&quot;cat&quot;&gt;
&lt;arg value=&quot;&amp;lt;&quot; /&gt;
&lt;arg value=&quot;foo&quot; /&gt;
&lt;/exec&gt;
</pre></td>
<td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
</tr>
<tr>
<td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
<td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
<td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
</tr>
</table>
</div>
<p>This will not do what you expect. The input-redirection is
performed by your shell, not the command itself, so this
should read:</p>
<div align="left">
<table cellspacing="4" cellpadding="0" border="0">
<tr>
<td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
<td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
<td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
</tr>
<tr>
<td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
<td bgcolor="#ffffff"><pre>
&lt;exec executable=&quot;/bin/sh&quot;&gt;
&lt;arg value=&quot;-c&quot; /&gt;
&lt;arg value=&quot;cat &amp;lt; foo&quot; /&gt;
&lt;/exec&gt;
</pre></td>
<td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
</tr>
<tr>
<td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
<td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
<td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
</tr>
</table>
</div>
<p>Note, that you must use the <code>value</code> attribute of
<code>&lt;arg&gt;</code> in the last element.</p>
</blockquote>
</td></tr>
</table>
</a>
<a name="integration">
<table border="0" cellspacing="0" cellpadding="2" width="100%">


+ 50
- 0
webpage/xdocs/faq.xml View File

@@ -196,6 +196,56 @@

</answer>
</faq>

<faq id="shell-redirect-1">
<question>How do I include a &lt; character in my command line arguments?</question>
<answer>
<p>The short answer is "Use <code>&amp;lt;</code>".</p>

<p>The long answer is, that this probably won't do what you
want anyway, see <a href="#shell-redirect-2">the next
section</a>.</p>
</answer>
</faq>

<faq id="shell-redirect-2">
<question>How do I redirect standard input or standard output
in the <code>&lt;exec&gt;</code> task?</question>
<answer>
<p>Say you want to redirect the standard input stream of the
<code>cat</code> command to read from a file, something
like</p>

<source><![CDATA[
shell-prompt> cat < foo
]]></source>
<p>and try to translate it into</p>

<source><![CDATA[
<exec executable="cat">
<arg value="&lt;" />
<arg value="foo" />
</exec>
]]></source>

<p>This will not do what you expect. The input-redirection is
performed by your shell, not the command itself, so this
should read:</p>
<source><![CDATA[
<exec executable="/bin/sh">
<arg value="-c" />
<arg value="cat &lt; foo" />
</exec>
]]></source>

<p>Note, that you must use the <code>value</code> attribute of
<code>&lt;arg&gt;</code> in the last element.</p>

</answer>
</faq>

</faqsection>

<faqsection title="Ant and IDEs/Editors">


Loading…
Cancel
Save