Is there a way to run the BASH built-in commands from Python?
I tried:
subprocess.Popen(['bash','history'],shell=True, stdout=PIPE)
subprocess.Popen('history', shell=True, executable = "/bin/bash", stdout=subprocess.PIPE)
os.system('history')
and many variations thereof. I would like to run history
or fc -ln
.
I finally found a solution that works.
Thank you everyone for the input.
this calls bash and tells bash to run the string
type type
, which runs the builtin commandtype
on the argumenttype
.output:
type is a shell builtin
the part after
-c
has to be one string. this will not work:["bash", "-c", "type", "type"]