Getting upload and download speeds with the help of script?How?

How can I get the upload and download speed of my pc, provided that my interface is wlan0?
I have though something like:

#!/bin/sh
ups=something
downs=somethingelse
echo "
         Your current up speed is $ups
     Your current down speed is $downs

, but I have no idea how to get them?Are they written to a file for a second or something or what? Thx for the help! I am quite good in scripting and not a beginner so don't be too descriptive! :smiley:

The only way to test your upload/download speed is to download/upload something from somewhere thats pretty close to you and has enough bandwith to never bee the bottleneck for you, so you're sure to minimize any thing that might scew the result.

Conky - Conky - Home - has variables for upload/download for interfaces that can show you this on your desktop.

Well actually, I want to make a script which will say me :Your current up speed is blabla and your current down speed is blabla"
I have desklets which can do this but I want to do this with the help of script!:cool:

---------- Post updated 03-06-10 at 02:41 AM ---------- Previous update was 03-05-10 at 07:21 PM ----------

Conky doesn't suits me really. I need a script...Is it that hard?

---------- Post updated at 06:32 PM ---------- Previous update was at 02:41 AM ----------

So, how can an aplication take the upload and download speed?

hmm...

create a 1mb dummy file... upload it somewhere, then retrieve it. while uploading and retrieve use the time command to give you an idea of how long it took then do some math to figure out your speeds.

dd if=/dev/zero of=~/1mb.txt bs=1024 count=1024

then whatever command your using to push it somewhere... put time in front of it. then take the output and do some calculations.

I suck at math or I would probably write it up for you.

Hmmmm.That's a good idea, but very difficult to take instant up and down speed, too many calculations, but I'll try it out. (I don't think so that programs that take upload and download speed work like that although)