Robsmith
Robsmith

Reputation: 473

Running Script from Another Script Using os.system

I have two scripts, the first, mail.py, scrapes hyperlinks from emails. The second, scrape.py, scrapes data from the links using Selenium and BeautifulSoup.

I have been using os.system('start cmd /c python scrape.py '+ link + ' && exit') to run scrape.py when a new email with a link arrives.

Sometimes I get an error with scrape.py but when I run it by manually inserting the link it works ok.

I'm new to python and I've read that os.system can be unstable. Is that correct? Is it likely to be the cause of the problem?

I'm under time pressure to finish the project so would prefer to keep the code as is unless that is the cause.

Upvotes: 1

Views: 64

Answers (1)

Yuri Khristich
Yuri Khristich

Reputation: 14537

You can try to run the python script without call cmd:

os.system('python scrape.py '+ link)

Upvotes: 2

Related Questions