#!/usr/bin/perl

use strict;

my @domhubs=(
	     'sps-ichub-cont01',
	     'sps-ichub-cont02',
	     'sps-ithub-cont01',
	     );

foreach my $domhub(@domhubs){
  print "Initializing TESTDAQ on hub '$domhub'\n";
  system("ssh", "-fnX", "$domhub", "bin/testdaq_remote_init");
}
# OK, this is very ugly, but the something is broken with the 
# shell on SPS. Shells just hang when nohuped processes are started in them
open(PS,"ps -x|") || die "Can't run 'ps -x': $!";
sleep 5;
while(<PS>){
  if(/testdaq_remote_init/){
    my ($pid,undef)=split;
    system('kill','-2',$pid);
  }
}
	     
