#!/usr/bin/perl -w # Runs wclient with given parameters on the host (and interface) given # by RUNAT environment variable. sub get_output { my @a=@ARGV; my $output = "delay_stats"; while ($#a >= 0) { if ($a[0] eq "-o") { $output = $a[1]; }; shift @a; } return $output; } @run_at = qw!localhost localhost localhost/wlan1!; @run_at = split(/ +/, $ENV{'RUNAT'}) if $ENV{'RUNAT'}; $i = 0; my %outputs; foreach $run (@run_at) { ($host, $iface) = split(/\//, $run, 2); @args = (); push @args, ('ssh', $host) if ($host ne 'localhost'); push @args, ('wclient'); push @args, ('-I', $iface) if (defined $iface); push @args, @ARGV; $output = get_output(); $output .= sprintf("-%s%s", $host, defined $iface ? "-$iface":""); if ($outputs{$output}) { $output .= sprintf("-%02d", $i); } $outputs{$output} = 1; push(@args, ('-o', $output)); if (fork() == 0) { print "running ", join(' ', @args), "\n"; exec(@args); exit(); } $i++; } foreach $run (@run_at) { wait(); }