1

When i write on terminal:

./sherlock *.txt

it works

but when I try to do the same using python subprocess like

import subprocess 
subprocess.call(['./sherlock','*.txt'])


import subprocess
subprocess.call('./sherlock','*.txt',shell=True)

import subprocess
subprocess.call('./sherlock','*.txt',shell=False)

Neither of this is working please help.

Vipul
  • 566
  • 5
  • 29

1 Answers1

7

Shell expand *, subprocess.call does not. Expand the * yourself using glob.glob.

And beside that, the argument that represent the command to be issued should be a list or a string object (not multiple arguments).

import glob
import subprocess
subprocess.call(['./sherlock'] + glob.glob('*.txt'), shell=False)
falsetru
  • 357,413
  • 63
  • 732
  • 636