Reputation: 2345
I am running a python script which is using subprocess to execute "history" command on my Ubuntu terminal. Apparently,I am getting this error
history: not found
I got to know that history can not be invoked by any script by default. What can I do to overcome this? Or any other possible alternatives.
readline.get_history_item() method isnt working either.
Upvotes: 1
Views: 1378
Reputation: 26688
Use this:
from subprocess import Popen, PIPE, STDOUT
e = Popen("bash -i -c 'history -r;history' ", shell=True, stdin=PIPE, stdout=PIPE, stderr=STDOUT)
output = e.communicate()
Upvotes: 4