#!/usr/bin/perl # Batch EXecutor -- Operations on a Job # (c) 2011-2015 Martin Mares use strict; use warnings; use Getopt::Long; use BEX; my $edit; my $long; my $queue_name; sub usage() { print <] [] If a job-id is given, print information on the given job. Otherwise, list all known jobs. Options: -e, --edit Run editor on the given job (no locking) -l, --long When listing jobs, use long format (with subjects) -q, --queue= Act on the given queue AMEN exit 0; } GetOptions( "e|edit!" => \$edit, "l|long!" => \$long, "q|queue=s" => \$queue_name, "help" => \&usage, ) && @ARGV <= 1 or die "Try `bex job --help' for more information.\n"; my $queue = BEX::Queue->new($queue_name); if (!@ARGV) { my @jobs = $queue->all_job_ids; for my $id (sort @jobs) { if ($long) { my $job = $queue->job_metadata($id); my $has_att = -d $queue->attachment_dir($id); print $job->name; print " +ATT" if $has_att; print "\n"; } else { print $id, "\n"; } } exit 0; } my $jid = $queue->resolve_job_id($ARGV[0]); my $fn = $queue->job_file($jid); if ($edit) { system "editor", $fn; } else { system "cat", $fn; }