View Single Post
Posts: 299 | Thanked: 557 times | Joined on Aug 2012
#4568
Originally Posted by Schturman View Post
Here one for test: ...
Ok I experienced the stuck issue as well and changed the script, please follow the instructions and test again. Once it works for you (I have 100% success rate with ~ 50 tests) I will build a dialog menu for you to make this look right.


Dependencies (only needed once): dialog + bc
Code:
devel-su
cd /home/user/MyDocs/Downloads/
wget https://www.dropbox.com/s/a7qncxnt4hs4e7w/dialog_1.0-20060221-3_armel.deb?dl=1
dpkg -x dialog_1.0-20060221-3_armel.deb /opt/extrautils
wget https://www.dropbox.com/s/y1jnb91cpxqgsx6/bc_1.06.95-2%2Bmaemo9%2B0m6_armel.deb?
dl=1
dpkg -x bc_1.06.95-2+maemo9+0m6_armel.deb /opt/extrautils

Script:
Code:
#!/bin/sh

URL="http://dl.dropbox.com/u/17706605/N9_QuickTweak_en_v9.4.pdf"
FILE=$(basename $URL)
rm -f $FILE
length=$(curl --head $URL 2>&1 | grep Content-Length | awk '{print $2}')
length_kb=$(($length >> 10))
scale=$(echo "scale=6; 100/$length" | /opt/extrautils/usr/bin/bc)
wget $URL 2>/dev/null &

(
while ( true )
do
    proc=$(ps aux | grep -v grep | grep wget | grep $FILE )
    if [[ "$proc" == "" ]]; then break; fi
    size=$(ls -l $FILE 2>/dev/null | awk '{print $5}' 2>/dev/null)
    if [ "$size" != "" ]; then
        {
            metre=$(printf %.0f $(echo "$size*$scale" | /opt/extrautils/usr/bin/bc))
        }
    fi

    echo "XXX"
    echo "file: $FILE"
    echo "size: $length_kb kb"
    echo "Please standby ..."
    echo "XXX"
    echo $metre

done
) | /opt/extrautils/usr/bin/dialog --title " N9 QuickTweak Updater " --no-collapse --gauge "Download Test" 8 40
/opt/extrautils/usr/bin/dialog --title " N9 QuickTweak Updater " --infobox "$FILE successfully downloaded" 4 40
exit 0

Don't worry about size of boxes, colours etc. All this is will be themed as you want once it works for you.
 

The Following User Says Thank You to brkn For This Useful Post: