2 # Batch EXecutor 3.0 -- 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";
12 Getopt::Long::Configure('require_order');
14 "home=s" => \$bex_home,
18 Usage: bex <general-options> <command> <command-options> <args>
21 --home=<dir> Home directory where all queues and config files reside
22 --lib=<dir> Directory where BEX modules are installed
24 Commands (and aliases):
25 add (a) Add new jobs to a queue
26 job Operations on queued jobs
27 ls List known machines and groups
28 prun (pr) Parallel version of `run'
29 queue (q) Show queues and jobs
30 run (r) Run queued jobs
35 print "BEX 3.0 (c) 2011-2012 Martin Mares <mj\@ucw.cz>\n";
37 ) or die "Try `bex --help' for more information.\n";
38 Getopt::Long::Configure('default');
41 die "BEX home directory $bex_home does not exist.\n";
43 if (!-d "$bex_home/BEX") {
44 die "BEX home directory $bex_home does not contain the BEX subdirectory.\n";
46 if (!-f "$bex_lib/perl/BEX.pm") {
47 die "BEX library directory $bex_lib misconfigured.\n";
50 @ARGV or die "Missing subcommand.\n";
51 my $sub = shift @ARGV;
52 $sub =~ /^[0-9a-zA-Z]+$/ or die "Invalid subcommand $sub\n";
60 if (defined $aliases{$sub}) { $sub = $aliases{$sub}; }
62 my $sub_path = "$bex_lib/bin/$sub";
63 -x $sub_path or die "Unknown subcommand $sub\n";
65 $ENV{"BEX_HOME"} = $bex_home;
66 $ENV{"BEX_LIB"} = $bex_lib;
67 $ENV{"PERL5LIB"} = join(":", $bex_lib . "/perl", $ENV{"PERL5LIB"} // ());
68 exec $sub_path, @ARGV;
69 die "Cannot execute $sub_path: $!\n";