#!/usr/bin/perl -w
use lib '/home/sam/krang-farm/lib';
use KrangFarm::Machine;
# loop through all configured machines
foreach $name (KrangFarm::Machine->list()) {
$machine = KrangFarm::Machine->new(name => $name);
$machine->start();
# call the date command and extract the output
$spawn = $machine->spawn(command => 'date');
if ($spawn->expect(5, -re => qr/^.*?\d{4}\r?\n/)) {
print "The date on $name is " . $spawn->match();
}
# stop the machine
$machine->stop();
}
Example 5: Script that starts each machine on the farm.
Back to Article