import subprocess output = subprocess.check_output(['ls *.dat'], shell=True) print(output)