Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Seti stats

by orthanc (Monk)
on May 24, 2000 at 14:02 UTC ( [id://14522]=sourcecode: print w/replies, xml ) Need Help??
Category: Utility / Web
Author/Contact Info Orthanc
Description: An Anon Monk sent in something similar to SOPW so I modified the code a bit and here it is. Could do with a bit more error checking but it works.
#!/usr/bin/perl
      use LWP::Simple;

      $|              = 1;
      $url            = "http://setiathome.ssl.berkeley.edu/cgi-bin/cg
+i?cmd=user_stats&email=";
      $email          = "INSERT DEFAULT EMAIL HERE";
      $res_okay       = 1;

      $email = $ARGV[0] if(defined $ARGV[0]);
      $email =~ s/@/%40/g;

      @html=get("$url$email");

      foreach (@html) {
              $_=~s/\cM//g;
              $_=~s/<(br|p)>/\n\n/ig;
              $_=~s/<(?:[^>'"]*|(['"]).*?\1)*>//gs
      }

      foreach (@html) {
              chomp($_);
              m/(.*@.*)/;
              $user = "$1";
              m/returned: (.*)/;
              $received = "$1";
              m/this rank: (\d*)/;
              $peers = "$1";
              m/rank out of (\d*).*is: (\d*)/;
              $rank = "$2/$1";
              m/ (\d*)\n(\d* hr \d* min)\n(\d* hr \d* min \d*?\.\d*)/;
              $results = "$1";
              $cputime = "$2";
              $avgworktime = "$3";
              m/(\d*?\.\d*%)/;
              $morework = $1;
              $res_okay = 0 if(/No user with that name was found/);
              }

      if($res_okay) {
              print "Seti stats ($user)\n";
              print "      Results: $results\n";
              print " Tot CPU Time: $cputime\n";
              print "Avg Work Time: $avgworktime\n";
              print "  Last Result: $received\n";
              print "         Rank: $rank (Peers $peers)\n";
              print "   \% Position: $morework\n";
      } else {
              print "No details for : $email\n";
      }
Replies are listed 'Best First'.
Re: Seti stats
by Hielo (Sexton) on Apr 17, 2003 at 20:31 UTC
    OK, I am a complete newbie, reading everythign I can't ge t my hands on and thought this would be a good palce to start (as I am a SETI buff), on running this (and entering my email address) this is what I get (with the -w modifier).
    C:\Perl\snips>perl -w setistats.pl Possible unintended interpolation of @stny in string at setistats.pl l +ine 6. Name "main::stny" used only once: possible typo at setistats.pl line 6 +. Use of uninitialized value in substitution (s///) at setistats.pl line + 15. Use of uninitialized value in substitution (s///) at setistats.pl line + 16. Use of uninitialized value in substitution (s///) at setistats.pl line + 17. Use of uninitialized value in scalar chomp at setistats.pl line 21. Use of uninitialized value in pattern match (m//) at setistats.pl line + 22. Use of uninitialized value in string at setistats.pl line 23. Use of uninitialized value in pattern match (m//) at setistats.pl line + 24. Use of uninitialized value in string at setistats.pl line 25. Use of uninitialized value in pattern match (m//) at setistats.pl line + 26. Use of uninitialized value in string at setistats.pl line 27. Use of uninitialized value in pattern match (m//) at setistats.pl line + 28. Use of uninitialized value in concatenation (.) or string at setistats +.pl line 2 9. Use of uninitialized value in pattern match (m//) at setistats.pl line + 30. Use of uninitialized value in string at setistats.pl line 31. Use of uninitialized value in string at setistats.pl line 32. Use of uninitialized value in string at setistats.pl line 33. Use of uninitialized value in pattern match (m//) at setistats.pl line + 34. Use of uninitialized value in pattern match (m//) at setistats.pl line + 36. Seti stats () Results: Tot CPU Time: Avg Work Time: Last Result: Rank: / (Peers ) Use of uninitialized value in concatenation (.) or string at setistats +.pl line 4 6. % Position:
    -- Is it something simple i am doing wrong? Any help would be appreciated.

      I recommend using vek's SETI::WebStats instead. It makes writing a Seti@home stats script so much easier.

      From the synopsis:

      use SETI::WebStats; my $emailAddr = "foo\@bar.org"; my $seti = SETI::WebStats->new($emailAddr); my $ranking = $seti->rank; my $unitsProcd = $seti->numResults; my $userInfo = $seti->userInfo; for (keys(%$userInfo)) { print $_, "->", $userInfo->{$_}, "\n"; }

        Thanks for taking the time to point it out, seems there are a ton of resources available to us.
        I am still figuring out how to install packages, what i can use for an IDE and the like. If you have any pointers, they would be appreciated.
        I have the O'reilly books and am getting through "Learning Perl", it is a fun read, not the dry tome I expected.
        Thanks again! Best regards, Bill

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: sourcecode [id://14522]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (5)
As of 2024-04-19 22:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found