I want to use glob pattern like this in subprocess.call function:
>>> subprocess.call(["ls", "output*"])
ls: cannot access output*: No such file or directory
2
>>> subprocess.call(["ls", "output\*"])
ls: cannot access output\*: No such file or directory
2
But cannot use glob(*)
pattern after filename "output"
above.
Globbing (expanding the *) is a function of your shell. You need to add the shell=True
parameter to execute the command through a shell interpreter.
subprocess.call("ls output*", shell=True)