-
-
Save codezixo/9721bef5ca9478bed601542c52cb1fa8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# bash 4.1.5(1) Linux Ubuntu 10.04 Date : 2011-10-09 | |
# | |
# _______________| netspeed : check download speed via command line. | |
# | |
# Usage: netspeed [tokyo, london, usw, use, east, westm, rbx, sbg, bhs URL] | |
# Default server is RBX FR. | |
# First try it out without any arguments. | |
# | |
# Dependencies: wget | |
# | |
# CHANGE LOG get LATEST version from https://bitbucket.org/rsvp/gists/src | |
# | |
# 2011-10-09 Add rate conversion to Mbps using negated first argument. | |
# 2011-10-08 Add URL as possible arg. Clarify rate units. | |
# Public as gist to https://gist.github.com/1272488 | |
# 2011-10-07 First version based on wget, though curl also works: | |
# http://stackoverflow.com/questions/426272 | |
# Command line alternative to http://www.speedtest.net | |
# | |
# 2014-12-27: (UPDATED BY MLWALK3R) | |
#- Removed a bunch of useless text | |
#+ Added more locations to download from | |
#* changed some hosts to better ones | |
#* Defalut host is now RBX | |
#* wget now shows Mb/s | |
# _____ Prelims | |
set -u | |
# ^ unbound (i.e. unassigned) variables shall be errors. | |
set -e | |
# ^ error checking :: Highly Recommended (caveat: you can't check $? later). | |
# | |
# _______________ :: BEGIN Script :::::::::::::::::::::::::::::::::::::::: | |
site=${1:-'rbx'} | |
case $site in | |
'london') test='http://ipv4.speedtest-lon1.digitalocean.com/100mb.test' ;; | |
# LON1 (London) | |
'tokyo') test='http://speedtest.london.linode.com/100MB-london.bin' ;; | |
'sgp') test='http://ipv4.speedtest-sgp1.digitalocean.com/100mb.test' ;; | |
# SGP1 (Singapore) | |
'gra') test='http://lg.walk3r.com/100MB.test' ;; | |
# GRA (Gravelines, France) | |
'rbx') test='http://ipv4.rbx.proof.ovh.net/files/1Gb.dat' ;; | |
# RBX (Roubaix, France) | |
'sbg') test='http://ipv4.sbg.proof.ovh.net/files/1Gb.dat' ;; | |
# SBG (Strasbourg, France) | |
'bhs') test='http://ipv4.bhs.proof.ovh.net/files/1Gb.dat' ;; | |
# BHS (Beauharnois, QC, Canada) | |
'ams') test='http://speedtest-ams3.digitalocean.com/100mb.test' ;; | |
# AMS3 (Amsterdam) | |
'usw') test='http://speedtest.fremont.linode.com/100MB-fremont.bin' ;; | |
# US West: Fremont, California | |
'use') test='http://speedtest.newark.linode.com/100MB-newark.bin' ;; | |
# US East: Newark, New Jersey | |
'east') test='http://speedtest.wdc01.softlayer.com/downloads/test500.zip' ;; | |
# US East: Washington, D.C. | |
'west') test='http://speedtest.sjc01.softlayer.com/speedtest/speedtest/random500x500.jpg' ;; | |
# US West: San Jose, California | |
*) test=$1 ;; | |
# valid URL assumed, else wget will give any error message. | |
esac | |
# Test file sources: | |
# digitalocean, softlayer, OVH, linode. | |
if [ $test = -${test#-} ] ; then | |
# ^check for negative sign in the first argument. | |
echo "`awk "END { print ($test * -0.007813) }" /dev/null` Mbps" | |
# awk as nice floating-point calculator! | |
else | |
echo ' :: Speed rate is in megabits/sec: ' | |
echo ' :: [Terminate netspeed by control-C] [ cf. http://speedtest.net ] ' | |
echo ' :: ' | |
# MAIN | |
wget --report-speed=bits --output-document=/dev/null $test | |
fi | |
exit 0 | |
# _______________ EOS :: END of Script :::::::::::::::::::::::::::::::::::::::: |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment