title: Execute command from query
body: <p>I intend to send an email through the result of a query. the problem is that it is being printed instead of running the command. can someone explain to me what i am doing wrong?</p>
  
  <pre><code>sqlTxt=$(sqlplus -s "$CONNECT" &lt;&lt; EOF 
     WHENEVER SQLERROR EXIT SQL.SQLCODE;
  
     SET FEEDBACK OFF
     SET HEADING OFF
     SET SERVEROUTPUT ON
     SET FEED OFF
     SET TERMOUT OFF
     SET VERIFY OFF
     SET ECHO OFF
     SET HEAD OFF
  select 'echo -en '||cme.BODY ||' |  mailx -s '||cme.SUBJECT ||' -a "$HTMLFILE"'||decode(MAIL_FROM,null,'',' -r "&lt;' ||MAIL_FROM|| '&gt;"')||' -c "'||MAIL_CC||'" "'||MAIL_TO||'"' send  from CUST_SEND_EMAIL cme WHERE  cme.program_name='SEND_EMAIL' and  cme.status='NOK';
  /
  EOF
  )
  
  $sqlTxt
  </code></pre>
  
  <p>Some additional notes:</p>
  
  <ul>
  <li><code>cme.BODY</code> contains <code>\n</code> . for this reason I use <code>echo -en</code></li>
  <li>i am using <code>mailx</code> because i found the simplest to work</li>
  <li>it is not mandatory to use the command as I did. I can assign to variables the content of each column resulting from the query (which I tried to do without success).</li>
  </ul>
  
  <p>Someone can help me?</p>
  
  <p>Thanks in advance</p>