Call external program from Python and capture its output

Credit goes to this Stack Overflow post, and this Stack Overflow post.
Using Python 2.7.3. This example calls ls with the -l option:

#!/usr/bin/python
# -*- coding: utf-8 -*-
 
from subprocess import check_output
 
output = check_output(["ls", "-l"])
print(output)

Comments

Popular Posts