Reply
Thread Tools
Posts: 103 | Thanked: 21 times | Joined on Sep 2012 @ romania
#4581
Reboot not help.i reinstall now n9qt and try again
 
Posts: 103 | Thanked: 21 times | Joined on Sep 2012 @ romania
#4582
After reinstall work ok.thanks.when u release new version?
 
Posts: 299 | Thanked: 557 times | Joined on Aug 2012
#4583
Hello Schturman,

This gave me a lot of headache but I finally worked it out. Bright side is no dependencies needed at all.
You can modify the bar charcacters as well as the length of the bar. Remember you can put a max of 45 characters in the bar because you have a start [ and end ] character which makes a total of 47 characters which is indeed are the max columns of N9 terminal. If you like we can get a landscape mod for this script.


Code:
#!/bin/bash

bar="============================================="
barlength=${#bar}

URL="https://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}' | sed 's/.$//')
wget $URL 2>/dev/null &

while [ ! -f $FILE ] ;
do
      sleep 0.1
done

i=1

while [[ $i -lt $length ]]; do
  i=$(stat "$FILE" | grep Size | awk '{print $2}')
  n=$(($i * $barlength / $length))
  printf "\r[%-${barlength}s]" "${bar:0:n}"
  sleep 0.2
done
echo ""

Last edited by brkn; 2012-11-10 at 15:53. Reason: formatting
 

The Following 3 Users Say Thank You to brkn For This Useful Post:
Schturman's Avatar
Posts: 5,339 | Thanked: 4,133 times | Joined on Jan 2010 @ Israel
#4584
Thanks
But weird, i get this error:
Code:
WAIT! Downloading PDF instruction...
/opt/N9QTweak/Tweaks/downloader.sh: line 24: Illegal number: n
But file downloaded...
curl And wget installed..
 
Posts: 299 | Thanked: 557 times | Joined on Aug 2012
#4585
Originally Posted by Schturman View Post
Thanks
But weird, i get this error:
Code:
WAIT! Downloading PDF instruction...
/opt/N9QTweak/Tweaks/downloader.sh: line 24: Illegal number: n
But file downloaded...
curl And wget installed..
I can only guess what goes wrong here. Are you executing the script with "sh script.sh"? You need to run it with "bash script.sh"!!
 
Schturman's Avatar
Posts: 5,339 | Thanked: 4,133 times | Joined on Jan 2010 @ Israel
#4586
Originally Posted by brkn View Post
I can only guess what goes wrong here. Are you executing the script with "sh script.sh"? You need to run it with "bash script.sh"!!
Ohhh.. You are right, sorry
It work but it show only bar...
Can we somehow combine it with your previous script where we can see the percentage status too ?:
Code:
download()
{
    local url=$1
    echo -n "    "
    wget --progress=dot $url 2>&1 | /opt/N9QTweak/SYS/bin/grep --line-buffered "%" | \
        /opt/N9QTweak/SYS/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_QuickTweak_en_v9.4.pdf"
echo -n "Downloading status:"
download "$file"
 
Posts: 299 | Thanked: 557 times | Joined on Aug 2012
#4587
Originally Posted by Schturman View Post
Ohhh.. You are right, sorry
It work but it show only bar...
Can we somehow combine it with your previous script where we can see the percentage status too ?:
Code:
download()
{
    local url=$1
    echo -n "    "
    wget --progress=dot $url 2>&1 | /opt/N9QTweak/SYS/bin/grep --line-buffered "%" | \
        /opt/N9QTweak/SYS/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_QuickTweak_en_v9.4.pdf"
echo -n "Downloading status:"
download "$file"
So you want
Code:
[=====        ]
50%
or

Code:
 [=====        ] 50%

this?
 
Schturman's Avatar
Posts: 5,339 | Thanked: 4,133 times | Joined on Jan 2010 @ Israel
#4588
 
Posts: 299 | Thanked: 557 times | Joined on Aug 2012
#4589
Originally Posted by Schturman View Post
second one
thanks
Code:
#!/bin/bash

bar="========================================"
barlength=${#bar}
URL="https://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}')
wget -q $URL 2>/dev/null &

while [ ! -f "$FILE" ] ;
do
      sleep 0.1
done

i=$(stat "$FILE" | grep Size | awk '{print $2}')

while [[ $i -lt $length ]]; do
  i=$(stat "$FILE" | grep Size | awk '{print $2}')
  n=$(($i * $barlength / $length))
  percent=$((100 * $i / $length))
  printf "\r[%-${barlength}s]" "${bar:0:n}"
  printf " $percent%%"
  sleep 0.1
done
printf "\n"
 

The Following 2 Users Say Thank You to brkn For This Useful Post:
Schturman's Avatar
Posts: 5,339 | Thanked: 4,133 times | Joined on Jan 2010 @ Israel
#4590
Yeaaaa ! It's perfect! Thank you very much!
P.S. Update come in one-two days.. Also version for N950

Last edited by Schturman; 2012-11-11 at 05:57.
 
Reply

Tags
hebrew vkb, n9 qtweak, n9 quick tweak, n9 quicktweak, root-ssh


 
Forum Jump


All times are GMT. The time now is 13:03.