2 # Batch EXecutor -- Master Program
3 # (c) 2012 Martin Mares <mj@ucw.cz>
9 my $bex_home = $ENV{"BEX_HOME"} // ".";
10 my $bex_lib = $ENV{"BEX_LIB"} // "lib";
14 Usage: bex <general-options> <command> <command-options> <args>
17 --home=<dir> Home directory where all queues and config files reside
18 --lib=<dir> Directory where BEX modules are installed
20 Commands (and aliases):
21 add (a) Add new jobs to a queue
23 job Operations on queued jobs
24 mach List known machines and groups
25 prun (pr) Parallel version of `run'
26 qman Management of queues
27 queue (q) Show queues and jobs on them
28 run (r) Run queued jobs
33 Getopt::Long::Configure('require_order');
35 "home=s" => \$bex_home,
37 "help" => \&show_help,
39 print "BEX 3.0 (c) 2011-2012 Martin Mares <mj\@ucw.cz>\n";
41 ) or die "Try `bex help' for more information.\n";
42 Getopt::Long::Configure('default');
45 die "BEX home directory $bex_home does not exist.\n";
47 if (!-d "$bex_home/cf") {
48 die "BEX home directory $bex_home does not contain the cf subdirectory.\n";
50 if (!-f "$bex_lib/perl/BEX.pm") {
51 die "BEX library directory $bex_lib misconfigured.\n";
54 @ARGV or die "Missing subcommand.\n";
55 my $sub = shift @ARGV;
56 $sub =~ /^[0-9a-zA-Z]+$/ or die "Invalid subcommand $sub\n";
58 if ($sub eq 'help') { show_help(); }
66 if (defined $aliases{$sub}) { $sub = $aliases{$sub}; }
68 my $sub_path = "$bex_lib/bin/bex-$sub";
69 -x $sub_path or die "Unknown subcommand $sub\n";
71 $ENV{"BEX_HOME"} = $bex_home;
72 $ENV{"BEX_LIB"} = $bex_lib;
73 $ENV{"PERL5LIB"} = join(":", $bex_lib . "/perl", $ENV{"PERL5LIB"} // ());
74 exec $sub_path, @ARGV;
75 die "Cannot execute $sub_path: $!\n";