User Tools

Site Tools


en:linux:scripts:cr

/mnt/pctotem31/bin/cr

A convenience tool to run srcam/cmsRun/runTotemDQM by one command.

#!/bin/bash

searchDirs=("." "$CMSSW_BASE/src" "$CMSSW_BASE/user")

function PrintUsage()
{
	echo "USAGE:	cr [-b dir] [-bf dir] [cfg file] [cfg file] ..."
}

if [ -z "$1" ]
then
	PrintUsage
	exit 1
fi

# default executable
executable="cmsRun"

# loop over arguments
while [ -n "$1" ]
do
	case "$1" in
		-b*)
			# building part
			opt=$1
			opt=${opt##-b}

			shift
			echo ">> Building $1" >&2
			dir="$CMSSW_BASE/src/$1"
			if [ ! -d "$dir" ]
			then
				echo "	ERROR: Module $dir doesn't exist."
				exit 1
			fi

			cd "$dir"
			sc b "-$Opt"
			result="$?"
			cd - > /dev/null

			if [ "$result" -ne "0" ]
			then
				echo "	ERROR during build"
				exit 1
			fi
			;;	

		"-d")
			executable='runTotemDQM'
			;;

		"-c")
			executable='cmsRun'
			;;

		*)
			# running part
			found="0"
			for dir in ${searchDirs[@]}
			do
				if [ -f "$dir/$1" ]
				then
					echo ">> Running $executable $dir/$1" >&2
					found="1"
					$executable "$dir/$1"
					break
				fi
			done

			if [ "$found" -ne "1" ]
			then
				echo ">> File $1 not found in any of search directories."
			fi
			;;
	esac

	shift
done
en/linux/scripts/cr.txt · Last modified: 2010/01/19 14:19 (external edit)