title: How to get stdout and stderr from a tmux session?
body: <p>I am writing a sample python program in linux system. I am using <a href="https://linux.die.net/man/1/tmux" rel="noreferrer">tmux</a> to create a session and execute another script within the tmux-session. I would like to get the stdout and stderr out of the tmux session to the parent script but that somehow does not work. </p>
  
  <p>Code snippet:</p>
  
  <pre><code>cmd = "tmux new-session -d -s 'test' '/my_dir/fibonacci.py __name:=fibonacci_0'"
  
  proc = Popen(cmd, shell=True, stdout=PIPE, stderr=PIPE)
  
  (stdout, stderr) = proc.communicate()
  
  print(stderr)
  </code></pre>
  
  <p>I have came across answers to use <a href="https://stackoverflow.com/a/24720356/1800026">show-buffer</a> and <a href="https://stackoverflow.com/a/43014752/1800026">pipe-pane</a>. But that did not help. Maybe I need to modify the tmux command itself. </p>