Line Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
#! /bin/bash

# The script is used to query file list from DBS
# use ./getrun.sh -h for help on the usage
#
#                           Dayong WANG June, 2009

function usage {

    echo "Usage: "
    echo "    1) query file list with run number and dataset name: ./getrun.sh -r RUNNUMBER (datasetname)"
    echo "    2) query file list with run number range [MIN, MAX) and dataset name:  ./getrun.sh  RUNNUMBER_MIN  RUNNUMBER_MAX (datasetname)"

}


while getopts ":r:h" opt; do
    case $opt in

	r)
	    if [ $# -eq 2 ]; then
		mydataset="/Cosmics/Commissioning08_CRAFT_ALL_V9_225_ReReco_FromTrackerPointing_v1/RECO"
	    elif [ $# -eq 3 ]; then
		mydataset=$3
	    elif [ $# -eq 0 ]; then
		echo "please provide the run number and (data set name) to query!"
		exit 2
	    fi

	    ./DDSearchCLI.py --verbose=0 --limit=-1 --input="find file where run=$OPTARG and dataset=$mydataset" | grep "root"
	    ;;
	\?)
	    echo "Invalid option: -$OPTARG" >&2
	    exit 1
	    ;;
	h)
	    usage
	    ;;
	:)
	    echo "Option -$OPTARG requires an argument to specify run number query  mode" >&2
	    exit 1
	    ;;
    esac
    exit 0
done

if [ $# -eq 2 ]; then
    mydataset="/Cosmics/Commissioning08_CRAFT_ALL_V9_225_ReReco_FromTrackerPointing_v1/RECO"
elif [ $# -eq 3 ]; then
    mydataset=$3
elif [ $# -lt 2 ]; then
    echo "please provide the range of run numbers and (data set name) to query!"
    exit 2
fi

./DDSearchCLI.py --verbose=0 --limit=-1 --input="find file where run >= $1 and run < $2 and dataset=$mydataset" | grep "root"