View Single Post
Schturman's Avatar
Posts: 5,339 | Thanked: 4,133 times | Joined on Jan 2010 @ Israel
#4561
Originally Posted by brkn View Post
It is not working because $COLUMNS for curl can't be initialised/accessed from your script unless you had tput for example to get the columns. Workarounds involve unbuffered use of grep and sed.

Note: Harmattan dev repository is down for me atm but I mirrored all ~ 15 gb of packages so I figured for the demo I would just upload those two needed packages to my dropbox account.
I put together some script below. Before you have to install newer version of grep and sed which support unbuffered option.

To do this, open terminal and type (only needed once):
Code:
devel-su
cd /home/user/MyDocs/Downloads/
wget https://www.dropbox.com/s/83k1xf63hg3pzzt/grep_2.6.3-3%2Bmaemo1%2B0m6_armel.deb?dl=1
dpkg -x grep_2.6.3-3+maemo1+0m6_armel.deb /opt/extrautils
wget https://www.dropbox.com/s/hsn5jggyx5mrioq/sed_4.2.1-7%2Bmaemo1%2B0m6_armel.deb?dl=1
dpkg -x sed_4.2.1-7+maemo1+0m6_armel.deb /opt/extrautils
Download script (feel free to modify):
Code:
#!/bin/sh
# little downloader for Schturman's awesome N9 QuickTweak app

download()
{
    local url=$1
    echo -n "    "
    wget --progress=dot $url 2>&1 | /opt/extrautils/bin/grep --line-buffered "%" | \
        /opt/extrautils/bin/sed -u -e "s,\.,,g" | awk '{printf("\b\b\b\b%4s", $2)}'
    echo -ne "\b\b\b\b"
    echo " DONE"
}

file="http://dl.dropbox.com/u/17706605/n9-qtweakall_9.4_armel.deb"
echo -n "Downloading stuff:"
download "$file"
Output looks like:
Code:
~/MyDocs/Downloads $ sh test.sh 
Downloading stuff: 59%
PS: thank you so much by the way for you app - it is great and I really do appreciate it!
Tested right now, work perfectly ! Thank you !
Tell me something.. We can not shorten the progress bar in CURL and what with WGET ? Can we add short (for portrait mode) progress bar to wget command, not only percentage?
Something like:
Code:
Downloading status:
[=====>       ] 59%
or
Code:
Downloading status:
[#######      ] 59%
or something else ?

Last edited by Schturman; 2012-11-08 at 22:41.