0

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.

smci
  • 32,567
  • 20
  • 113
  • 146
mkzia
  • 33
  • 4

1 Answers1

1

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)
ILostMySpoon
  • 2,399
  • 2
  • 19
  • 25