You can use subprocess.check_output
:
In [864]: output = subprocess.check_output(['objdump -d a.out'], shell=True)
This returns a byte string of your output. You may then use str.decode
to display your data. If you want to indent with a tab, you can just split on newline and then print line by line, like this:
In [870]: for line in output.decode().split('\n'):
...: print('\t', line)
...:
a.out: file format Mach-O 64-bit x86-64
Disassembly of section __TEXT,__text:
__text:
100000fa0: 55 pushq %rbp
100000fa1: 48 89 e5 movq %rsp, %rbp
100000fa4: 31 c0 xorl %eax, %eax
100000fa6: c7 45 fc 00 00 00 00 movl $0, -4(%rbp)
100000fad: 5d popq %rbp
100000fae: c3 retq
_main:
100000fa0: 55 pushq %rbp
100000fa1: 48 89 e5 movq %rsp, %rbp
100000fa4: 31 c0 xorl %eax, %eax
100000fa6: c7 45 fc 00 00 00 00 movl $0, -4(%rbp)
100000fad: 5d popq %rbp
100000fae: c3 retq