I'm having a bit of trouble. I want to run a shell command within Python in a specific directory. Based on the code I found on the internet I need the following inclusions:
import os
import subprocess
import shlex
And then the code itself is below
os.chdir('/etc/test/')
cmd = 'scrapy crawl test'
subprocess.call(shlex.split(cmd))
As it looks like, I am trying to run the command "scrapy crawl test" within the /etc/test/ directory. When I run this manually with terminal it seems to work fine however when I run it with this python code it gives me an error:
INFO Exception occured while scraping: [Errno 2] No such file or directory
Is anyone able to tell me if my code is incorrect, or if I am going about this the wrong way perhaps.