How to capture bash command output using python script.
For eg:
running below in linux :
[root@xxxxxx oracle]# echo sumit
sumit
[root@xxxxxx oracle]#
How can i re print only the above output using python script ? like running python test.py shoud give 'sumit' as output. i tried below:
test.py :
import sys
sys.stdout.flush()
out = sys.stdin.readline()
print(out)
Above prints only the input i type but not the already displayed output
subprocessmodule to execute shell commands from Python and capture the output.