Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<blockquote> <p>this works:</p> <pre><code>nc shldvgfas005 6155 &lt; temp.6153 </code></pre> <p>this hangs:</p> <pre><code>cmd="nc shldvgfas005 6153 &lt; temp.6153"; $cmd </code></pre> </blockquote> <p>The difference you see here is due to the shell parsing redirection operators before parameter expansions.</p> <blockquote> <p>this gives an error:</p> <pre><code>cmd="nc shldvgfas005 6153 &lt; temp.6153"; "$cmd" -bash: nc shldvgfas005 6153 &lt; temp.6153: command not found </code></pre> </blockquote> <p>This command fails because the quotes around the parameter expansion prevent it from being split into multiple fields. The shell tries to find a single executable named <code>nc shldvgfas005 6153 &lt; temp.6153</code> (i.e. there are embedded spaces in the filename), but fails to find any such file. Also, the redirection does not happen due to the same reason as the first failure.</p> <p>For the details of your shell’s parsing, consult its manual (or that of a related shell; possibly the <a href="http://www.opengroup.org/onlinepubs/009695399/utilities/xcu_chap02.html" rel="nofollow noreferrer">POSIX Shell Command Language specification</a>). In general, all Bourne-like shells parse redirections before expansions. So the redirection operator can not be part of a variable (though the redirection source/target (filename) can be a variable). Some folks like to use <em>eval</em> to make stuff like this work, but it is a bad idea unless you are fully aware of the security implications.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload