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
If you are using
shell=Trueyou must pass a string tosubprocess.call, not a list. See http://docs.python.org/library/subprocess.html#subprocess.call for more details.However, invoking subprocess with
shell=Trueis not recommended due to security implications. You should removeshell=Trueand leave the list-style args.