title: Check if there is an stdout redirection in bash script
body: <p>I need to check if my program's output is being redirected; if yes I need to keep and send its by mail.</p>
  
  <p>example:</p>
  
  <pre><code>$ myprogram -param1 -param2 -param3 &gt; /home/polly/log.txt
  </code></pre>
  
  <p><code>myprogram.sh</code>:</p>
  
  <pre><code>if 'redirection is not empty'; then 
      cat &lt;redirection name&gt; | mailx -s "This is a test email." polly@gmail.com 
  fi 
  </code></pre>