Adjust some perl & tcl related things in various scripts & utilities.
[dragonfly.git] / tools / tools / mid / mid-master
CommitLineData
52b73b16 1#!/usr/pkg/bin/perl
984263bc
MD
2
3if ($#ARGV < 1) {
4 die "usage master counter command comandargs ... \n";
5}
6
7$count = $ARGV[0]; shift @ARGV;
8@command = @ARGV;
9$file = pop(@command);
10undef @ARGV;
11$debug = 0;
12
13for($i = 0; $i < $count; $i ++) {
14 @c = (@command, "$file.$i");
15 warn "Start process: $i @c\n" if $debug;
16 open("OUT$i", "| @c") || die "open @c\n";
17 select("OUT$i"); $| = 1;
18}
19select(STDOUT);
20
21$n = 0;
22while(<>) {
23 $o = 'OUT' . ($n % $count);
24 print $o $_;
25 warn "$o $_" if $debug;
26 $n++
27}
28
29for($i = 0; $i < $count; $i ++) {
30 warn "Close process $i\n" if $debug;
31 close("OUT$i") || warn "close OUT$i: $!\n";
32}
33