[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

os count



Did did a little perl program that does an os count produces count like
hp-ux   3
linux      1
sunos    38.

Run as a stand alone did not see the need to run out of hobbit.
But Henrik wouldn't this be easy enough to add in to bbtest?
Here it is:

#!/usr/local/bin/perl
eval 'exec /usr/local/bin/perl -S $0 ${1+"$@"}'
   if $running_under_some_shell;
                       # this emulates #! processing on NIH machines.
                       # (remove #! line above if indigestible)

eval '$'.$1.'$2;' while $ARGV[0] =~ /^([A-Za-z_0-9]+=)(.*)/ && shift;
                       # process any FOO=bar switches

$[ = 1;                 # set array base to 1
$BBHOME="/home/mnemeth/sunhobbit/";
open (HOB, "$BBHOME/server/bin/bb 127.0.0.1 'hobbitdboard fields=BBH_OS test=info' |") ;

while (<HOB>) {
   chomp;      # strip record separator
   @Fld = split(' ', $_, -1);

   for ($i = 1; $i <= $#Fld; $i++) {
       $freq{$Fld[$i]}++;
   }
}

foreach $word (sort keys %freq) {
   printf "%s\t%d\n", $word, $freq{$word};
}