Downloading file from internet - timing it

Microsoft Running ms-dos 20th anniversar...
February 21, 2010 at 13:39:24
Specs: Windows XP
Hey I am trying to code a program which will allow me to download a file off my web server (a 1mb txt file to be exact) what i am trying to do is get some code to run in a batch file which will download the file and then calculate the time taken to get the file (therefore working out connection speed) anyone have any ideas on how to do this?

See More: Downloading file from internet - timing it

Report •

February 21, 2010 at 16:51:01
maybe something like this:

@echo off & setlocal
> # echo open
>> # echo user myself
>> # echo mypassword
>> # echo binary
>> # echo get myfile
>> # echo quit
set strt=%time%
ftp -n -s#
set stop=%time%
call subtime %strt% %stop%

if you want the code for subtime let me know. i wrote it as a separate routine since it can be used by other processes.

Report •

February 21, 2010 at 17:06:03
The code for subtime as well would be much help.


Report •

February 22, 2010 at 00:11:59
usage: call subtime hh1:mm1:ss1.tt1 hh2:mm2:ss2:tt2
where tt is tenths, others are obvious.
ok, here it comes:

@echo off & setlocal enabledelayedexpansion
set time1=%1
set time2=%2
set n9=100
set n6=60
set n3=60
set n0=24
:: setup var.s: a9 a6 a3 a0 --> a91 a61 a31 a01; a92 a62 a32 a02
:: for hh,mm,ss,tenths; time1, time2 resp.
for /L %%a in (9 -3 0) do (
for /L %%c in (1 1 2) do (
set a%%a%%c=!time%%c:~%%a,2!
:: have to do this part because of octal crap. (08=10) (see set /?)
set test=!a%%a%%c:~0,1!
if !test! equ 0 set a%%a%%c=!a%%a%%c:~1!
set /a a%%a%%c+=xx
set /a z%%a=xx+a%%a2-a%%a1
if !z%%a! lss 0 (
set /a xx=-1
set /a z%%a+=n%%a
) else (
set xx=0
:: take this out whenever you want - just testing!
call :test
echo %z0%:%z3%:%z6%.%z9%
goto :eof

:: just display for debugging
for /L %%b in (1 1 2) do (
echo a%%a%%b: !a%%a%%b! z%%a: !z%%a!
goto :eof

please let me know if it f__s up! I try to test my stuff, but often endusers encounter problems i did not anticipate.
thanks for your response.

Report •

Related Solutions

February 22, 2010 at 01:53:26
also, apologies, forgot this was DOS.
subtime will have to be handled diff. if native DOS system.
let me know, might be able to work it.

Report •

Ask Question