I was wondering how to find out the current progress of work units. So I did some snooping. I quickly found I could
grep the answer. But it wasn't "
pretty". So I dove into Perl (which I have been attempting to learn). I am proud of my solution. I hope to continue to develop. Anyway, I'll include the script here for those who'd like to give it a try.
My only request is that you maintain the original by-line.
I don't know how well this will come out here, but I'll give it a try:
#!/usr/bin/perl
# by Chip Griffin (n1mie@mac.com)
# 04/15/2005
#
# Gets current percentage by looking in the client state file.
my $filename = '/Applications/boinc/client_state.xml';
# change the path to work for you
# the filename shouldn't change
open FILE, $filename or die "Can't open '$filename': $!";
# trap error for opening the file
my @strings = <FILE>; # extract file contents
my @matches = eval {
grep /fraction/, @strings; # look for the desired data
};
foreach $number (@matches) {
$number =~ s|</*fraction_done>||g; # strips xml codes
$number =~ s| *||g; # strips leading spaces
chomp($number); # get rid of end-of-line characters
if ($number < 1) { # necessary since Predictor gives weird numbers
$number *= 100; # makes it into a whole number
};
$number = int(($number * 10) + 0.5) / 10;
# change multiply/divide numbers in multiples
# of ten to change number decimal places to keep
$number .= "% completen"; # adds text to lines
};
print @matches; # output the formatted data
Good luck.