Page 2 of 2 FirstFirst 12
Results 11 to 19 of 19

Thread: Wget and zenity --progress

  1. #11
    Join Date
    Apr 2006
    Location
    Montana
    Beans
    Hidden!
    Distro
    Kubuntu Development Release

    Re: Wget and zenity --progress

    Quote Originally Posted by Martje_001 View Post
    bodhi.zazen: Why didn't you add a sleep in the loop..? this consumes way too much CPU.
    Um, err, the dog ate it ?
    There are two mistakes one can make along the road to truth...not going all the way, and not starting.
    --Prince Gautama Siddharta

    #ubuntuforums web interface

  2. #12
    Join Date
    Jul 2006
    Location
    Ecuador
    Beans
    32
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: Wget and zenity --progress

    wow I like sed more and more but even more the examples helping me understand the manual.

    This was cool

  3. #13
    Join Date
    Jul 2006
    Location
    Ecuador
    Beans
    32
    Distro
    Ubuntu 10.04 Lucid Lynx

    Wink Re: Wget and zenity --progress

    Hi I used this hack for a while but now in jaunty things seem to be different? Anyway, the second line works for me in jaunty:
    Code:
    wget http://(url) 2>&1 | sed -u 's/.*\ \([0-9]\+%\)\ \+\([0-9.]\+\ [KMB\/s]\+\)$/\1\n# Downloading \2/' | zenity --progress --title="Downloading" --auto-close
    wget http://(url) 2>&1 | sed -u 's/.* \([0-9]%\)\ \+\([0-9.]\+.\) \(.*\)/\1\n# Downloading at \2\/s, ETA \3/' | zenity --progress --title="Downloading" --auto-close
    my wget version in jaunty is GNU Wget 1.11.4. To mee it seems spaces are not backslashed anymore (?)

  4. #14
    Join Date
    Jul 2006
    Location
    Ecuador
    Beans
    32
    Distro
    Ubuntu 10.04 Lucid Lynx

    Thumbs up Re: Wget and zenity --progress

    Quote Originally Posted by gigahz View Post
    Code:
    second line:
    wget http://(url) 2>&1 | sed -u 's/.* \([0-9]%\)\ \+\([0-9.]\+.\) \(.*\)/\1\n# Downloading at \2\/s, ETA \3/' | zenity --progress --title="Downloading" --auto-close
    Sorry, I forgot to include more than one percentage digit, see the \+ just before % below:
    Code:
    second line:
    wget http://(url) 2>&1 | sed -u 's/.* \([0-9]\+%\)\ \+\([0-9.]\+.\) \(.*\)/\1\n# Downloading at \2\/s, ETA \3/' | zenity --progress --title="Downloading" --auto-close
    Anyway, this version includes Estimated Time of Arrival for the impatient

  5. #15
    Join Date
    Aug 2009
    Beans
    11
    Distro
    Ubuntu 10.04 Lucid Lynx

    Lightbulb Re: Wget and zenity --progress

    This is good, but there is still some problems. instead I use named pipes and not anonymous pipes to transfer wget result to zenity . my code is :
    Code:
    DOWNLOAD() {
      rand="$RANDOM `date`"
      pipe="/tmp/pipe.`echo '$rand' | md5sum | tr -d ' -'`"
      mkfifo $pipe
      wget -c $1 2>&1 | while read data;do
        if [ "`echo $data | grep '^Length:'`" ]; then
          total_size=`echo $data | grep "^Length:" | sed 's/.*\((.*)\).*/\1/' |  tr -d '()'` 
        fi
        if [ "`echo $data | grep '[0-9]*%' `" ];then 
          percent=`echo $data | grep -o "[0-9]*%" | tr -d '%'` 
          current=`echo $data | grep "[0-9]*%" | sed 's/\([0-9BKMG.]\+\).*/\1/' ` 
          speed=`echo $data | grep "[0-9]*%" | sed 's/.*\(% [0-9BKMG.]\+\).*/\1/' | tr -d ' %'` 
          remain=`echo $data | grep -o "[0-9A-Za-z]*$" ` 
          echo $percent
          echo "#Downloading $1\n$current of $total_size ($percent%)\nSpeed : $speed/Sec\nEstimated time : $remain"
        fi
      done > $pipe &
    
      wget_info=`ps ax |grep "wget.*$1" |awk '{print $1"|"$2}'`
      wget_pid=`echo $wget_info|cut -d'|' -f1 `
    
      zenity --progress --auto-close --text="Connecting to $1\n\n\n" --width="350" --title="Downloading"< $pipe
      if [ "`ps -A |grep "$wget_pid"`" ];then
        kill $wget_pid
      fi
      rm -f $pipe
    }
    
    if [ $1 ];then
      DOWNLOAD "$1"
    else
      dllink=$(zenity --entry --text "Your download link :" --width="350" --entry-text "" --title="Download url")
      if [ $dllink ];then
        DOWNLOAD "$dllink"
      fi
    fi
    I'm still working on regexp and I know there is a lot better regexp than mine in this code but its work .
    You can use DOWNLOAD function for your scripts, just take one argument (download link) but I wrote complete example too.

    Again thanks to original idea of this script, the idea is from the 8th and 3rd post of this thread.

    The complete information about this code available on my blog but in Persian (farsi)
    Last edited by fzerorubigd; August 18th, 2010 at 08:56 AM.

  6. #16
    Join Date
    Mar 2005
    Location
    in your local area networ
    Beans
    15

    Re: Wget and zenity --progress

    Quote Originally Posted by gigahz View Post
    Sorry, I forgot to include more than one percentage digit, see the \+ just before % below:
    Code:
    second line:
    wget http://(url) 2>&1 | sed -u 's/.* \([0-9]\+%\)\ \+\([0-9.]\+.\) \(.*\)/\1\n# Downloading at \2\/s, ETA \3/' | zenity --progress --title="Downloading" --auto-close
    Anyway, this version includes Estimated Time of Arrival for the impatient
    That was cool.

    Thanks it is pretty usefoul.

  7. #17
    Join Date
    Nov 2008
    Beans
    Hidden!
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: Wget and zenity --progress

    Could you adapt the script to work with axel, instead of wget?

  8. #18
    Join Date
    Mar 2008
    Beans
    40
    Distro
    Ubuntu 10.10 Maverick Meerkat

    Re: Wget and zenity --progress

    hope to see a script for axel please.

    i tried but not working

    Code:
    axel -a http://(url) 2>&1 | sed 's/.* \([0-9]\+%\).* \([0-9]\+.[0-9]\)\(.*\)].*\[\([0-9]\+:[0-9]\+\).*/\1\n#Speed: \2\3 - Estimated time: \4/' | zenity --progress --title="Downloading"

  9. #19
    Join Date
    Jun 2006
    Location
    London
    Beans
    54
    Distro
    Ubuntu 7.04 Feisty Fawn

    Talking Re: Wget and zenity --progress

    Quote Originally Posted by fzerorubigd View Post
    this is good, but there is still some problems. Instead i use named pipes and not anonymous pipes to transfer wget result to zenity . My code is :
    Code:
    download() {
      rand="$random `date`"
      pipe="/tmp/pipe.`echo '$rand' | md5sum | tr -d ' -'`"
      mkfifo $pipe
      wget -c $1 2>&1 | while read data;do
        if [ "`echo $data | grep '^length:'`" ]; then
          total_size=`echo $data | grep "^length:" | sed 's/.*\((.*)\).*/\1/' |  tr -d '()'` 
        fi
        if [ "`echo $data | grep '[0-9]*%' `" ];then 
          percent=`echo $data | grep -o "[0-9]*%" | tr -d '%'` 
          current=`echo $data | grep "[0-9]*%" | sed 's/\([0-9bkmg.]\+\).*/\1/' ` 
          speed=`echo $data | grep "[0-9]*%" | sed 's/.*\(% [0-9bkmg.]\+\).*/\1/' | tr -d ' %'` 
          remain=`echo $data | grep -o "[0-9a-za-z]*$" ` 
          echo $percent
          echo "#downloading $1\n$current of $total_size ($percent%)\nspeed : $speed/sec\nestimated time : $remain"
        fi
      done > $pipe &
    
      wget_info=`ps ax |grep "wget.*$1" |awk '{print $1"|"$2}'`
      wget_pid=`echo $wget_info|cut -d'|' -f1 `
    
      zenity --progress --auto-close --text="connecting to $1\n\n\n" --width="350" --title="downloading"< $pipe
      if [ "`ps -a |grep "$wget_pid"`" ];then
        kill $wget_pid
      fi
      rm -f $pipe
    }
    
    if [ $1 ];then
      download "$1"
    else
      dllink=$(zenity --entry --text "your download link :" --width="350" --entry-text "" --title="download url")
      if [ $dllink ];then
        download "$dllink"
      fi
    fi
    i'm still working on regexp and i know there is a lot better regexp than mine in this code but its work .
    You can use download function for your scripts, just take one argument (download link) but i wrote complete example too.

    Again thanks to original idea of this script, the idea is from the 8th and 3rd post of this thread.

    +1 +1 +1

Page 2 of 2 FirstFirst 12

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •