Linux – Capturing yum progress bar percentage


I would like to know if it's possible to capture download progress i.e percentage download complete shown by 'yum' while it's downloading a package. Capture, in the sense, could be to a text file or programatically using JAVA, for an instance, if I run the yum installer from JAVA.

I've tried yum install pkg_name > captured, but it captures the standard output only without the progress information.

I've also checked stderr, no result.


Setting up Install Process Resolving Dependencies

--> Running transaction check

---> Package wget.i686 0:1.12-4.fc14 set to be installed

--> Finished Dependency Resolution

Dependencies Resolved

================================================================================ Package Arch Version Repository Size


Installing: wget i686 1.12-4.fc14 updates 481 k

Transaction Summary

================================================================================ Install 1 Package(s)

Total download size: 481 k

Installed size: 1.8 M Downloading Packages:

Running rpm_check_debug

Running Transaction Test

Transaction Test Succeeded

Running Transaction

Installing : wget-1.12-4.fc14.i686 1/1


Wget.i686 0:1.12-4.fc14


Along with the above info, I'd also like to the capture the progress part i.e percentage complete that is shown below the 'Downloading Packages:' label while downloading.

I don't use Python scripts.

Best Answer

The progress bars are written out only when the output is going to terminal. You may simulate that with using expect (with ExpectJ being Java implementation) but parsing application output (thing called screen scraping) can be very fragile method and would break when output changes, for example depending on width of output terminal, length of package names and perhaps other things.

Yum is written in python and is extensible with plugins so you may try to write a plugin to talk to your application and notify on the progress, but it does not look worth the trouble to me.

Here are the docs if you decided to go that way.

To simply wrap yum in an expect you can use something like:

#!/usr/bin/expect -f
set timeout 600
spawn yum -y install zsh-html
expect eof

After this you can catch output and see packages being downloaded there.