views:

184

answers:

3

Hiya,

I have a php shell script that downloads a large file, it would be a bit of a luxury to be able to see the progress of the download in shell while it's happening, anyone have any idea how this can be achieved (or at least point me in the right direction!)

Thanks!

A: 

Read the header of the file to get the size of the file (if that information is available). Then keep track of how much you have downloaded and that will give you your percentage. How you might do that depends on what libraries/functions you are using.

Jan Hančič
+3  A: 

You could try to poll the filesize of the downloaded file as it's downloading, and compare it with the filesize of the file you requested.

+1  A: 

This seemed to work (unexpectedly!)

echo "wget '$feedURL'\n";
$execute = "wget -O ".$filePath." '$feedURL'\n";
$systemOutput = shell_exec($execute);
$systemOutput = str_replace( "\n", "\n\t", $systemOutput);
echo "\t$systemOutput\n";
Shadi Almosri