I did this before in Linux Mint.
1. Download a copy of the python script speediest-cli . Or copy and paste the code into a file and rename it.
2.On Ubuntu or Linux you have to make it a executable to run so open a terminal window and type 'sudo chmod a+x filename'.
Now if you type 'ls' to list what is in the directory you should see that the file name has changed color in my case green, Now its executable.
3. Run the file ' sudo python ./Filename. Thats it I think !!.
The 'a+x' I got off the internet some where it might not be the best practice but it works perfectly. Now you can schedule this to run when ever you want with crontab if you wish and pipe the results out to a file to have a look at later.
I hope this helps.
I have not been approved yet so I only get one post a day so I cant reply.
If you come across a way to change the servers for the speed test please let me know it could be useful Thanks !
Also I had a problem with 777 also and I found that above and it worked like a charm.