Folding@home (F@H) is the most powerful distributed computing cluster in the world and one of the world's largest distributed computing projects. The goal of the project is "to understand protein folding, misfolding, and related diseases."
f@h.pl prints out some information about your current work progress in irssi. Note: this script requires curl.1 #!/usr/bin/perl -w 2 # This program is free software; you can redistribute it and/or modify 3 # it under the terms of the GNU General Public License as published by 4 # the Free Software Foundation; either version 3 of the License, or 5 # (at your option) any later version. 6 # 7 # This program is distributed in the hope that it will be useful, 8 # but WITHOUT ANY WARRANTY; without even the implied warranty of 9 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 # GNU General Public License for more details. 11 # 12 # You should have received a copy of the GNU General Public License 13 # along with this program. If not, see <http://www.gnu.org/licenses/>. 14 # 15 # Folding @ Home script for irssi; requires curl installed 16 # 17 #*********************************** 18 # IMPORTANT: SET UP YOUR F@H-PATH! * 19 #*********************************** 20 21 use strict; 22 use Irssi; 23 use vars qw($VERSION %IRSSI); 24 $VERSION = '1.10'; 25 %IRSSI = ( 26 authors => 'Haui', 27 contact => 'haui45@web.de', 28 name => 'fah stats', 29 description => 'This script allows ' . 30 'you to print your ' . 31 'folding @ home stats in irssi', 32 license => 'GPL', 33 ); 34 35 #******************************************************************** 36 my $fahpath="/path/to/fah/"; #change to your f@h-path* 37 #******************************************************************** 38 39 40 my ($wu, $dltime, $duetime, $progress, $name, $team, @stats, $string, $line); 41 `which curl` or die "fatal...curl executable not found...."; 42 43 Irssi::print("fah stats successfully loaded! Response time of the script may vary, see code for details."); 44 45 sub irssi_stuff { 46 # server - the active server in window 47 # witem - the active window item (eg. channel, query) 48 # or undef if the window is empty 49 my ($data, $server, $witem) = @_; 50 51 if (!$server || !$server->{connected}) { 52 Irssi::print("Not connected to server"); 53 return; 54 } 55 my $ret = fah(); 56 if ($ret == -1){ 57 Irssi::print ("Please set your f\@h path!"); 58 return; 59 } 60 elsif ($ret == -2){ 61 Irssi:print("Problem with unitinfo.txt...is your path correct?"); 62 return; 63 } 64 elsif ($ret == -3){ 65 Irssi:print("Problem with client.cfg...is your path correct?"); 66 return; 67 } 68 elsif ($ret == -4){ 69 Irssi:print("something went wrong....fix it! :-) "); 70 return; 71 } 72 if ($witem && ($witem->{type} eq "CHANNEL" || 73 $witem->{type} eq "QUERY")) { 74 # there's query/channel active in window 75 $witem->command("SAY $string"); 76 } else { 77 Irssi::print("No active channel/query in window"); 78 } 79 } 80 81 sub fah { 82 my $curl = "curl &> /dev/null http://vspx27.stanford.edu/teamstats/team"; 83 my $unitinfo = $fahpath . "/unitinfo.txt"; 84 my $cfg = $fahpath . "/client.cfg"; 85 86 if ($unitinfo =~ m/^\/path\/to\/fah/){ #just in case... 87 return -1; 88 } 89 90 open(INFILE, "<", $unitinfo) or return -2; 91 92 while ($line = <INFILE>){ 93 if ($line =~ m/^Name:/) {$wu=$line; chomp($wu);} 94 elsif ($line =~ m/^Download/) {$dltime=$line; chomp($dltime);} 95 elsif ($line =~m/^Due/) {$duetime=$line; chomp($duetime);} 96 elsif ($line =~m/^Progress/) {$progress=$line; chomp($progress);} 97 } 98 close INFILE; 99 100 open (INFILE,"<", $cfg) or return -3; 101 102 while($line = <INFILE>){ 103 if ($line =~ m/^username/){ #get username 104 $name = $line; 105 $name =~ s/username=//; 106 chomp($name); 107 } 108 if ($line =~ m/^team/){ #get Team-Id 109 $team=$line; 110 $team =~ s/team=//; 111 chomp($team); 112 last; 113 } 114 } 115 close INFILE; 116 if ($team == 446 || $team == 0){ #remove this if your connection is fast enough... 117 die "teamstats file is too large ;p\n"; # 118 } # 119 120 $curl=$curl.$team.".txt > /tmp/team.txt"; 121 system($curl); 122 123 124 open(INFILE, "<", "/tmp/team.txt") or return -4; 125 my @array = <INFILE>; 126 @array = grep /\t$name\t/, @array; 127 @stats = split /\t/, $array[0]; 128 129 130 131 $string = "[stats] User: $name - Team: $team - team rank: $stats[1] - overall rank: $stats[0] - credit: $stats[3] ||
[wu] $wu - $dltime - $duetime - $progress"; 132 133 unlink("/tmp/team.txt"); 134 } 135 136 Irssi::command_bind('fah', 'irssi_stuff');