python, subprocess.call(["rm", "inv.mt0"], shell=True) not working
python, subprocess
Solution
If you are using `shell=True` you must pass a string to `subprocess.call`, not a list. See http://docs.python.org/library/subprocess.html#subprocess.call for more details.
However, invoking subprocess with `shell=True` is not recommended due to security implications. You should remove `shell=True` and leave the list-style args.
Problem
friends, I have a simple script ``` import subprocess subprocess.call(["./run_xf"]) old=open('./inv.mt0','r') lines=old.readlines() lines=lines[3:] new=open('./inv.mt1','w') new.writelines(lines) old.close() new.close() subprocess.call(["rm", "inv.mt0"], shell=True) ``` All the codes work except the last one. run_xf runs hspice and generate inv.mt0. then i copy part of inv.mt0 to inv.mt1. then i want to delete inv.mt0. But this doesn't work. For this specific example, it complains rm can't find operand. But if i write them together, it doesn't delete the file as well. thanks xf