[Tutor] Not sure how to use external command within python code (3.6)
Robert Alexander
bob at ralexander.it
Sat Dec 7 11:16:00 EST 2019
I wish to use Ookla's SpeedTest CLI (https://www.speedtest.net/apps/cli ) (after trying other Python libraries I didn't like).
I'd like to issue a "speedtest -f json" command from within a python script and parse the results.
I am currently stuck with the following code:
process = subprocess.Popen(['/usr/local/bin/speedtest', '-f json'],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
stdout, stderr = process.communicate()
which only populates the stderr variable stating that
[error] Invalid output format specified: json
Given on the command line that syntax is good.
What am I doing wrong?
Thank you very much
PS End goal will be monitoring the results and when they fall under a given threshold send me an email, but that's the final goal.
More information about the Tutor
mailing list