Run BASH built-in commands in Python?
I finally found a solution that works.
from subprocess import Popen, PIPE, STDOUTshell_command = 'bash -i -c "history -r; history"'event = Popen(shell_command, shell=True, stdin=PIPE, stdout=PIPE, stderr=STDOUT)output = event.communicate()
Thank you everyone for the input.
subprocess.Popen(["bash", "-c", "type type"])
this calls bash and tells bash to run the string type type
, which runs the builtin command type
on the argument type
.
output: type is a shell builtin
the part after -c
has to be one string. this will not work: ["bash", "-c", "type", "type"]