A quick and dirty upload/download speed calculator. 01.22.2007 17:24
Printer Friendly

Scenario: You're at work, you upload something BIG to your home machine. You leave work. You come home, you want to see the progress and you also want to know the speed of the upload/download. (if the connection stalled or not) (Our test file is: hda1.tar.gz)

You can try: watch ls -al hda1.tar.gz

But I wanted something more numeric :P Like bytes/sec, ETA, etc... : ) So I wrote this little script.

#!/bin/bash

# Usage:
# speed.sh <filename> [<filesize>]

clear
OLDFILESIZE=`ls -al "$1" | awk '{print \$5}'`
sleep 2
while true; do
 FILESIZE=`ls -al "$1" | awk '{print \$5}'`
 let "DIFF = $FILESIZE - $OLDFILESIZE"
 let "SPEED = $DIFF / 2 / 1024"
  if [ $2 ]
        then
         let "ETA = (($2*1024*1024) - $FILESIZE )*2 / $DIFF"
         let "ETAM = $ETA/60"
         echo "Filesize: $2MB | Downloaded: $FILESIZE bytes"
         echo "$1 download speed = $SPEED Kb/s  | ETA: $ETA s - $ETAM m"
  else
    echo "Downloaded: $FILESIZE bytes"
    echo "$1 download speed = $SPEED Kb/s"
  fi
    let "OLDFILESIZE = $FILESIZE"
   sleep 2
 clear
done

Pretty self explanatory : )

Back to Eblog

Latest two blog entries:
George Carlin died at the age of 71...
washington, DC has the worst metro system EVER


Make a comment!
Comments will be approved first to prevent suckers to misuse/abuse my comments section. So, there is a delay!
No html tags are allowed. Text is your friend ;)
I will never use your email for bad purposes, so, chill.. ;)

Date: 07.24.2008 17:20
Name:
Email:
URL:
Subject:
Comment:
Please type the number you see in this picture to the box below.


Comments:
sleeplessjojo <email-hidden> - 01.26.2007 18:18
script
euh... non... it's NOT self explanatory... the only explanation is that you are abusing of wandwith! ; )