title: Syntax error in sh file but command working on bash
body: <p>I am newbie with bash so it must be a little thing (I hope) but can not find the problem's source.</p>
  <p>I have a mysql database table called &quot;url&quot; full of urls. That I want is take all the list and visit them with wget. Nothing more.</p>
  <p>I had this command, and launching directly in bash works:</p>
  <pre><code>while read dbname; do dbarray+=(&quot;$dbname&quot;); done &lt; &lt;(mysql -u MYUSER -pMYPASSWD, -e 'select url from mydb.url where borrado=&quot;n&quot; and status=200 and id_idioma = 1 order by id_url asc' -B -N -s --skip-column-names) &amp;&amp; for dbname in `echo ${dbarray[*]}`; do wget --no-check-certificate $dbname -O /dev/null &gt; /dev/null 2&gt;&amp;1; done &amp;&amp; unset dbarray
  </code></pre>
  <p>But if I put it into a sh file and execute it throw a error (please note that line 3 is the command):</p>
  <p><code>line 3: Syntax error near unexpected token `&lt;'</code></p>
  <p>I tried to avoid &lt;() pipe method to &quot;traditional&quot; pipe but as same way, it works executing directly in bash as command but not in .sh file</p>
  <pre><code> mysql -u MYUSER -pMYPASSWD -e 'select url from mydb.url where borrado=&quot;n&quot; and status=200 and id_idioma = 1 order by id_url asc' -B -N -s --skip-column-names | while read dbname; do dbarray+=(&quot;$dbname&quot;); done &amp;&amp; for dbname in `echo ${dbarray[*]}`; do wget --no-check-certificate $dbname -O /dev/null &gt; /dev/null 2&gt;&amp;1; done &amp;&amp; unset dbarray
  </code></pre>
  <p>In this case not throw error, but it takes 1 second to finnish and do nothing, not visit any link..</p>
  <p>Tried executing <em>./myfile.sh</em> and <em>sh myfile.sh</em>, with no luck..</p>
  <p>Could you help me to make it work from a sh file or make me understand where is the problem?</p>
  <p>Please note it have 3 commands concatenated with &amp;&amp;: 1 take all urls and create a var with them, 2 loop var and wget each iteration, 3 delete var.
  I think is the correct way but maybe I'm wrong. Obviously must wait to finnish 1 to do 2, and to finnish 2 to do 3, is that I wanted. Is it the correct aproximation as you point of view?</p>
  <p>Cheers</p>