I have to print bash history using subprocess package.
import subprocess co = subprocess.Popen(['history'], stdout = subprocess.PIPE) History = co.stdout.read() print("----------History----------" + "\n" + History) but they prompt an error
Traceback (most recent call last): File "test.py", line 4, in <module> co = subprocess.Popen(['history'], stdout = subprocess.PIPE) File "/usr/lib/python2.7/subprocess.py", line 394, in __init__ errread, errwrite) File "/usr/lib/python2.7/subprocess.py", line 1047, in _execute_child raise child_exception OSError: [Errno 2] No such file or directory
shell=Truein the Popen call relevant questionPopenas recommended in its documentation. See perhaps further stackoverflow.com/a/51950538/874188