#!/usr/bin/env ruby #----------------------------------------------------------------------- # will look in dirname for the request files, for each request file # will call root script to do the concatenation # # example: # concatenate.rb /cdf/opr2/cdfopr/strip/sewk00/.requests 2004 10 20 #----------------------------------------------------------------------- require 'find' require 'fileutils' def usage puts "usage: catalog.rb request_file [debug]" exit(-1) end usage if ARGV.length < 1 directory = ARGV[0] pattern = "2004"; if ( ARGV[1] != "" ) ; pattern = ARGV[1] ; end jmin = 0 ; if ( ARGV[2] != "" ) ; jmin = ARGV[2].to_i ; end jmax = 0 ; if ( ARGV[3] != "" ) ; jmax = ARGV[3].to_i ; end debug = 0 ; if ( ARGV[4] != "" ) ; debug = ARGV[4].to_i ; end pwd=`pwd`.sub("\n","") puts "pwd = #{pwd} args = 0: #{ARGV[0]} 1: #{ARGV[1]} 2: #{ARGV[2]} 3: #{ARGV[3]} " puts directory puts "jmin = #{jmin} jmax = #{jmax}" list = Dir.entries(directory); list.each { |file| fn = file.split("/").last; if fn.index(pattern) == 0 #----------------------------------------------------------------------- # time to submit the job #----------------------------------------------------------------------- ok = 1; if jmin > 0 ; # test job number request_number = fn.split(".").last.to_i if ( request_number < jmin) || (request_number > jmax) ok = 0 end end puts " fn = #{fn} ok = #{ok}" if ok != 0 script=pwd + "/cdfopr/scripts/process_concatenation_request" rc=`#{script} #{directory}/#{file}` end end }