Veritas-bu

[Veritas-bu] SUMMARY: How2get robot control host for a robot?

2001-02-02 18:20:15
Subject: [Veritas-bu] SUMMARY: How2get robot control host for a robot?
From: W. Curtis Preston curtis AT backupcentral DOT com
Date: Fri, 02 Feb 2001 15:20:15 -0800
Thanks to Mike Wei for the nugget that eventually turned into the 
answer.  I've got two perl scripts below.

============================================================
First, here is the perl code to build a complete hash
of all the robots and their various control hosts
============================================================

#!/usr/local/bin/perl

open(VMQUERY, "vmquery -a |");

while ($line = <VMQUERY>) {
     next unless ( $line =~ /robot number|robot host/ ) ;
     chomp $line ;
     @tmp = split /\s+/, $line;
     if ( $line =~ /robot number/ ) { $robot_num = $tmp[2]} ;
     if ( $line =~ /robot host/ ) {
      $robot_host = $tmp[2] ;
      $robot_control_host{$robot_num} = $robot_host ;
     } ;
}

foreach $robot_num (keys %robot_control_host) {
     print "$robot_num\t$robot_control_host{$robot_num}\n";
}

===========================================================
With a slight modification, here is the perl code to get
the robot control host for robot 0:
===========================================================

#!/usr/local/bin/perl

$robot=0 ;

open(VMQUERY, "vmquery -a |");

while ($line = <VMQUERY>) {
     next unless ( $line =~ /robot number|robot host/ ) ;
     chomp $line ;
     @tmp = split /\s+/, $line;
     if ( $line =~ /robot number/ ) { $robot_num = $tmp[2]} ;
     if ( $line =~ /robot host/ ) {
      $robot_host = $tmp[2] ;
      $robot_control_host{$robot_num} = $robot_host ;

      #This next line is really the only difference.  If the robot number
      #of this robot matches the one we're looking for, we can quit now.
      #This will speed things up a bit.
      if ( $robot_num == $robot ) { last };

     } ;
}

$control_host = $robot_control_host{$robot} ;



<Prev in Thread] Current Thread [Next in Thread>
  • [Veritas-bu] SUMMARY: How2get robot control host for a robot?, W . Curtis Preston curtis <=