I am using Python( OSX Python 2.7.10) to ssh into a Debian box ( Python 2.7.9), then I run a bash script (./capture). The bash script contains some tcpdump commands. The problem I cant figure out is how to display the live results from the running bash script on the terminal.
#!/usr/bin/env python3
import subprocess, os
output = subprocess.run(["ssh", "ju@192.168.199.125", "sudo ./capture"])
print(output)
I am able to ssh , and run the script successfully, but I get no output. When I hit CTRL C I get the following trace:
**^CTraceback (most recent call last):
File "/Users/junesjoseph/run.py", line 3, in <module>
output = subprocess.run(["ssh", "junes@192.168.199.125", "sudo ./capture"])
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/subprocess.py", line 405, in run
stdout, stderr = process.communicate(input, timeout=timeout)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/subprocess.py", line 835, in communicate
self.wait()
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/subprocess.py", line 1457, in wait
(pid, sts) = self._try_wait(0)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/subprocess.py", line 1404, in _try_wait
(pid, sts) = os.waitpid(self.pid, wait_flags)
KeyboardInterrupt**
Any help is greatly appreciated. thanks