title: How to write the output of a command in netcat to a file?
body: <p>I am executing a command in localhost using Paramiko's exec_command and trying to write the output from localhost to a file.</p>
  
  <p>I tried the following command,</p>
  
  <pre><code>stdin, stdout, stderr=ssh_client.exec_command('echo "command" |nc localhost 6666 &gt; /opt/doc/Output.txt 2&gt;&amp;1')
  </code></pre>
  
  <p>The command is successfully executed and the result of the command is also being written for the first time. When executed repeatedly, it does not write. I need to close and open the server and then run the command again.</p>