first check-in of feisty meow codebase. many things broken still due to recent
[feisty_meow.git] / scripts / processes / runner.pl
1 #!/usr/bin/perl
2
3 ###############################################################################
4 #                                                                             #
5 #  Name   : runner                                                            #
6 #  Author : Chris Koeritz                                                     #
7 #  Rights : Copyright (C) 1991-$now by Author                                 #
8 #                                                                             #
9 #  Purpose:                                                                   #
10 #                                                                             #
11 #    Executes the programs in the current directory and combines their        #
12 #  outputs into one stream.                                                   #
13 #                                                                             #
14 ###############################################################################
15 #  This program is free software; you can redistribute it and/or modify it    #
16 #  under the terms of the GNU General Public License as published by the Free #
17 #  Software Foundation; either version 2 of the License or (at your option)   #
18 #  any later version.  See: "http://www.gruntose.com/Info/GNU/GPL.html" for a #
19 #  version of the License.  Please send any updates to "fred@gruntose.com".   #
20 ###############################################################################
21
22 require "importenv.pl";
23
24 $run_dir = ".";
25 if ($#ARGV >= 0) {
26   $run_dir = $ARGV[0];
27 }
28 #print "starting in directory $run_dir\n";
29
30 # float across the executables in this directory.
31 if ($OS =~ /UNIX/) {
32   foreach $i ( `find $run_dir -type f -perm +111` ) { &run_it($i); }
33 } else {
34   foreach $i ( `find $run_dir -iname "*.exe"` ) { &run_it($i); }
35 }
36
37 # the run_it function does the real work of writing out the log and executing
38 # the programs of interest.
39 sub run_it()
40 {
41   local($program_name) = @_;
42   chop $program_name;  # take off EOL.
43
44 #printf "program name is $program_name\n";
45
46   if ($program_name =~ /\.log$/) { return; }
47   print stderr "starting $program_name.\n";
48   print "\n";
49   print "\n";
50   print "---- starting $program_name ----\n";
51   # run the program now...
52   if ( ($OS eq "Windows_NT") || ($OS eq "Windows_95") ) {
53     # don't use nice when it doesn't exist.
54     system($program_name);
55   } else {
56     system("nice -4 " . $program_name);
57   }
58 # added nice in since some tests are brutal.
59   print "---- $program_name is done ----\n";
60   print "\n";
61   print "\n";
62   print stderr "ending $program_name.\n";
63 }
64