title: Shell script to email results of SQLPlus query using Mailx in AIX
body: <p>I have the commands that I need. If I execute these commands at the prompt, everything works as expected. SQLPlus runs the query, exports the result to a file and then Mailx emails that file to me.</p>
  
  <pre><code>sqlplus username/pwd@instance
  SPOOL /home/sadmin/sqlmail/spool.out
  set linesize 2000
  set wrap off
  @/home/sadmin/sqlmail/query.sql
  SPOOL OFF
  exit
  mail -s "Subject" email@address.com &lt; /home/sadmin/sqlmail/spool.out
  </code></pre>
  
  <p>But, I can not, for the life of me, figure out how to put these in an .sh file so that I can schedule it. Help!? And thanks in advance, I'm sure this is very silly.</p>