I'm making a script that wgets some pictures from a website and displays them. Basically it's a smart picture frame program that keeps up with a website that has it's pictures changed daily. I can't get Python's subprocess.run method to run a simple rm *.jpg:
subprocess.run(["rm", "-fv", "*.jpg"])
Alternativly I've tried:
subprocess.run(["rm", "*.jpg"])
I've done some trouble shooting and the top line there is what I've found flawed. The wget runs well and so does the rest of the script. The wget runs right after the rm:
subprocess.run(["wget", "-nd", "-p", "--accept=.jpg", "-e", "robots=off", "--reject=0.jpg", "--reject=8.jpg", "fnitemshop.com"])
I've tried adding the following lines before the rm but I've since commented out as they failed to fix my issue:
#subprocess.run(["chmod", "a+r+w+x", "*.jpg"])
#subprocess.run(["unlink", "*.jpg"])
I've also tried:
subprocess.run(["rm", "*.jpg"], shell=True)
Needless to say I'm a bit confused.
SOLUTION
Turns out that the issue was using double-quotes, should have done single quotes. Like so:
subprocess.run(['rm *.jpg'], shell=True)
Thanks to Tamaki Sakura for his answer to this question.