title: running a program through ssh fails with "Error opening terminal: unknown."
body: <p>When I try to execute a simple command through ssh, then it is successful. e.g.</p>
  
  <pre><code>#] ssh servername "echo abcd"
  abcd
  #] 
  </code></pre>
  
  <p>However, when I try the following command, it fails:</p>
  
  <pre><code>#] ssh servername  ~/htopmem.sh
  Error opening terminal: unknown.
  #] 
  </code></pre>
  
  <p>where the content of htopmem.sh is below. (inspired by the answer of Marwan Alsabbagh on <a href="https://stackoverflow.com/questions/17534591/htop-output-to-human-readable-file">htop output to human readable file</a>)</p>
  
  <pre><code>#!/bin/bash
  echo q | htop | sed -r "s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]//g" | ~/aha --black --line-fix | grep Mem | grep -E -o "[0-9]+/[0-9]+"
  </code></pre>
  
  <p>If I manually ssh to the server and run htopmem, then the execution is successful:</p>
  
  <pre><code>#] ./htopmem.sh
  6515/24021
  #] 
  </code></pre>
  
  <p>any idea on how to make the "ssh servername  ~/htopmem.sh" command work?</p>
  
  <p>Thank you!</p>