Firstly, there is very little space for passing an array:
subprocess.check_output(['/usr/bin/wc','-l','AZ*/AZ*.F*'], shell=True)
... since it just starts wc with no arguments, the arguments -l and AZ*/AZ*.F* are also passed in the shell as arguments (for the shell, not for wc ). Instead, you want:
subprocess.check_output('/usr/bin/wc -l AZ*/AZ*.F*', shell=True)
Before fixing, it freezes because wc has no arguments and reads from stdin. I would suggest that stdin be passed in private, and not passed through your Python program stdin (as by default).
An easy way to do this, since you have shell=True :
subprocess.check_output( '/usr/bin/wc -l AZ*/AZ*.F* </dev/null', shell=True)
... alternately:
p = subprocess.Popen('/usr/bin/wc -l AZ*/AZ*.F*', shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=None) (output, _) = p.communicate(input='')
... which will provide an empty stdin from Python code, rather than relying on the shell.
source share