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
  • 29,564
  • 18
  • 109
  • 144
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,379
  • 2
  • 16
  • 25