I just want to execute the command rm /tmp/*.idx
from a python script. I have read that os.system
is deprecated (IT IS NOT, see the comments), so I'm trying with Popen the following:
proc = subprocess.Popen(shlex.split('rm /tmp/*.idx'))
proc.communicate()
after of course importing shlex
and subprocess
, but it doesn't erase the files.
Thanks.
Glob patterns are shell syntax. So:
subprocess.Popen("rm /tmp/*.idx", shell=True)