title: top: failed tty get in linux
body: <pre class="lang-sh prettyprint-override"><code>#!/bin/bash
  echo &quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;
  now=`date &quot;+%m/%d/%y:%H:%M:%S&quot;`
  echo -e &quot;\n\n $now  ---CPU/MEM output--- \n\n&quot;
  cat /proc/cpuinfo
  echo -e &quot;\n\n&quot;
  cat /proc/meminfo
  echo -e &quot;\n\n&quot;
  echo `ulimit -a`
  now=`date &quot;+%m/%d/%y:%H:%M:%S&quot;`
  echo -e &quot;\n\n $now  ---top output--- \n\n&quot;
  export TERM=xterm
  top -n 1 -U username
  top -H -n 1 -U username
  echo -e &quot;\n END OF Script&quot;
  </code></pre>
  <p>Tried using</p>
  <pre><code>export Term 
  </code></pre>
  <p>still getting error as failed to get TTY.
  Please advice.</p>