Fixing bug #59470
[u/mrichter/AliRoot.git] / test / proof / prepareAlienCollection.sh
CommitLineData
33410957 1#!/bin/sh
2#############################################################################
3# prepareCollection.sh. Script to prepare a raw-data chunks collection
4# for a given run
5# Usage:
6# ./prepareCollection.sh <run_number> <collection_file>
7#############################################################################
8#
9# modification history
10# version 1.0 2008/09/12 Cvetan Cheshkov
11
12# SET THE FOLLOWING PARAMETERS IF NEEDED:
13# ---------------------------------------
14YEAR=09
15# ---------------------------------------
16
17RUNNUM=$1
18
19[ -z $RUNNUM ] && { echo "Please provide a run number..."; exit 1; }
20
21OUTFILE=$2
22
23[ -z $OUTFILE ] && { echo "Please provide an output filename..."; exit 1; }
24
25[ ! -e "$HOME/.globus/usercert.pem" ] && { echo "FAILED: There is no certificate in $HOME/.globus"; exit 1; }
26
27[ -e "/tmp/gclient_env_$UID" ] && { source /tmp/gclient_env_$UID; }
28alien-token-init
29
30[ ! "$?" -eq "0" ] && { echo "FAILED: Token creation failed"; exit 1; }
31
32# Retrieve the list of chunks from AliEn.......
33BASEDIR="/alice/data/20"$YEAR
34PATTERN="/raw/"$YEAR"0000"$RUNNUM"*0.root"
35rm -f collection.tmp
36gbbox find $BASEDIR $PATTERN | grep -v found | head --lines=-1 > collection.tmp
37
38[ $(stat -c%s collection.tmp) -eq 0 ] && { echo "No chunks found for the given run"; exit 1; }
39
40rm -f $OUTFILE
41for ifile in `cat collection.tmp` ; do echo "alien://$ifile" >> $OUTFILE 2>&1; done
42rm -f collection.tmp
43
44echo `cat $OUTFILE | wc -l`" raw-data chunks are found and added to the collection file "$OUTFILE;
45