title: executing mailx command in shell script
body: <p>I have a simple shell script that executes a .sql script.  When the .sql script has completed, the shell script sends an email to a specified address notifying whether or not the .sql script ran successfully.</p>
  
  <p>My problem is that the subject line is being truncated.  I am using a simple IF statement to determine the subject line:</p>
  
  <pre><code>grep 'ORA-' $OUTFILE &gt; /dev/null 2&gt;&amp;1
  if [ $? = 1 ]; then
      ERRORS=n
      SUBJECT= "$VERSION script successful"
  else
      ERRORS=y
      SUBJECT="$VERSION script had error(s)"
  fi
  </code></pre>
  
  <p>This works fine.  However, when I execute the mailx command, the subject line is truncated to "Development" or "Production" depending on the version of the script that has been executed:</p>
  
  <pre><code>mailx -s $SUBJECT $EMAIL &lt; $MAILFILE
  </code></pre>
  
  <p>I know the subject line needs to be in double quotes if it includes embedded spaces, but this does not seem to work correctly when assigned to a variable.</p>
  
  <p>Is there a way around this?  Is there a way to escape the double quotes </p>