Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

need help to calculate file download time

Status
Not open for further replies.

vijjay

Programmer
Feb 19, 2003
15
CA
I need to write Unix script file stat.sh that would contain a sequence of UNIX xommands that, when executed, will provide user with the downloading time of small.jpg and big.jpg files at the 28.8Kbps, 33.6Kbps, 50666bps dial up rates, 384Kbps aDSL and 500Kbps cable rate.

(Then with file stat.sh has to be called by other file through SSI "#exec" directive but I know how to make SSI one.)

And I was told that awk utilities are better to solve this problem.

I am just new in this field and have no clue at all what to do and how using Unix and/or awk.

I will appreciate any proper solution/guide or help.

Thanks,
Vijjay
 
This should do what you want.
[tt]#!/bin/bash

FILESIZE=$( ls -l $1 | awk '{
if ($5 ~ /^[0-9]+$/)
print $5
}' )
BITS=$( echo "($FILESIZE * 8) / 1024" | bc )
echo "28Kbps: $( echo "$BITS / 28" | bc ) seconds."
echo "33.6Kbps: $( echo "$BITS / 33.6" | bc ) seconds."
echo "50.6Kbps: $( echo "$BITS / 50.6" | bc ) seconds."
echo "384Kbps: $( echo "$BITS / 384" | bc ) seconds."
echo "500Kbps: $( echo "$BITS / 500" | bc ) seconds."[/tt] //Daniel
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top