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 (l) Show queues and jobs on them
28 mach List known machines and groups
29 prun (pr) Parallel version of `run'
30 queue Operations on queues
31 run (r) Run queued jobs
36 print "BEX 3.0 (c) 2011-2012 Martin Mares <mj\@ucw.cz>\n";
38 ) or die "Try `bex --help' for more information.\n";
39 Getopt::Long::Configure('default');
42 die "BEX home directory $bex_home does not exist.\n";
44 if (!-d "$bex_home/BEX") {
45 die "BEX home directory $bex_home does not contain the BEX subdirectory.\n";
47 if (!-f "$bex_lib/perl/BEX.pm") {
48 die "BEX library directory $bex_lib misconfigured.\n";
51 @ARGV or die "Missing subcommand.\n";
52 my $sub = shift @ARGV;
53 $sub =~ /^[0-9a-zA-Z]+$/ or die "Invalid subcommand $sub\n";
61 if (defined $aliases{$sub}) { $sub = $aliases{$sub}; }
63 my $sub_path = "$bex_lib/bin/$sub";
64 -x $sub_path or die "Unknown subcommand $sub\n";
66 $ENV{"BEX_HOME"} = $bex_home;
67 $ENV{"BEX_LIB"} = $bex_lib;
68 $ENV{"PERL5LIB"} = join(":", $bex_lib . "/perl", $ENV{"PERL5LIB"} // ());
69 exec $sub_path, @ARGV;
70 die "Cannot execute $sub_path: $!\n";