title: eval and string "return"
body: <p>Edit:
  I'm creating a bash script to run Netezza queries.</p>
  
  <p>here's an example of what I have to do:</p>
  
  <pre><code>nzsql -host localhost -port 123456 -d db -u usr -pw pwd -A -t -c "insert into TABLE (name,surname) values ('m','sc')"
  </code></pre>
  
  <p>and it should return</p>
  
  <pre><code>INSERT 0 1
  </code></pre>
  
  <p>What I need is retrieve the number "1" which means that 1 row was inserted.</p>
  
  <p>For this, I'd need to retrieve the whole string "INSERT 0 1" and work on it.</p>
  
  <p>according to <a href="http://www.enzeecommunity.com/thread/2423" rel="nofollow noreferrer">http://www.enzeecommunity.com/thread/2423</a> this should work:</p>
  
  <pre><code>cmnd_output=`nzsql -host $NZ_HOST -d $NZ_DATABASE -u $NZ_USER -pw $NZ_PASSWORD -A -t -c "insert into TEST values ('test 1')"`
  </code></pre>
  
  <p>But I can't get it to work with this: ($2 is right because when I run it from the terminal it works just fine)</p>
  
  <pre><code>cmd_out=`$2` or cmd_out=`"$2"` or cmd_out="`$2`" or cmd_out=`"'$2'"`
  cmd_out=$($2) or cmd_out="$($2)" or cmd_out=$("$2")
  </code></pre>
  
  <p>It tells me command not found... just like if there was a "string quote" problem with $2</p>
  
  <p>I've however managed to execute $2 with eval</p>
  
  <pre><code>eval "$2"
  </code></pre>
  
  <p>and it works great, the command $2 is executed just fine.
  But, I can't use eval in this case as I want to store in a variable that "INSERT 0 1".</p>