#!/usr/bin/env ruby require 'rbbt-util' require 'rbbt/util/simpleopt' #$0 = "rbbt #{$previous_commands*""} #{ File.basename(__FILE__) }" if $previous_commands options = SOPT.setup < Open.read(fcmd)).read.strip end if tail && File.exists?(File.join(dir, 'std.err')) if exit_status && exit_status != 0 puts Log.color(:magenta, "First error or exception found: ") puts CMD.cmd("grep -i -w 'error\\|[a-z]*exception' #{File.join(dir, 'std.err')} -A #{tail.to_i} |head -n #{tail.to_i}", :no_fail => true).read elsif exit_status puts Log.color(:magenta, "Completed jobs: ") puts CMD.cmd("grep -i -w 'Completed step' #{File.join(dir, 'std.err')} | grep -v 'Retrying dep.' | tail -n #{tail.to_i}", :no_fail => true).read else puts Log.color(:magenta, "Log tail: ") puts CMD.cmd("tail -n #{tail.to_i} #{File.join(dir, 'std.err')}").read end end count += 1 Open.rm_rf dir unless dry_run end puts puts "Found #{count} jobs"