ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitProd/Processing/bin/downloadFiles.sh
Revision: 1.2
Committed: Fri Dec 10 09:41:33 2010 UTC (14 years, 5 months ago) by ceballos
Content type: application/x-sh
Branch: MAIN
Changes since 1.1: +5 -1 lines
Log Message:
new code

File Contents

# User Rev Content
1 paus 1.1 #!/bin/bash
2     #---------------------------------------------------------------------------------------------------
3     # Download a list of files
4     #---------------------------------------------------------------------------------------------------
5    
6     # read the arguments
7     echo ""
8     echo "downloadFiles.sh $*"
9     echo ""
10     dataDir=$1; shift
11     book=$1; shift
12     dataset=$1; shift
13     target=$1; shift
14     condorOutput=$1; shift
15     first=$1; shift
16     last=$1; shift
17    
18     # prepare environment
19     echo " "
20     echo " Process dataset: $dataset of book: $book"
21     echo " in directory : $dataDir"
22     echo " to target : $target"
23     echo " condor output: $condorOutput"
24 ceballos 1.2 echo " file range : $first -- $last"
25 paus 1.1
26     mkdir -p $condorOutput/$book/$dataset
27     script=`which downloadFile.sh`
28    
29     # make sure the request is good
30 ceballos 1.2 nFiles=`wc -l $condorOutput/$book/$dataset/fileList.txt | cut -d ' ' -f 1`
31 paus 1.1 if [ $first -gt $nFiles ] || [ $last -gt $nFiles ]
32     then
33     echo "Request makes no sense: nFiles=$nFile but first=$first and last=$last"
34     exit 0
35     fi
36    
37     # see how many we do in this job
38     nFilesPerJob=$(($last - $first + 1))
39     fList=`head -$last $condorOutput/$book/$dataset/fileList.txt | tail -$nFilesPerJob | cut -d' ' -f 2`
40    
41 ceballos 1.2 echo LIST $fList
42     #exit 0
43    
44 paus 1.1 # spread the jobs out by a bit
45     sleep $first
46    
47     # loop through our list now
48     for file in $fList
49     do
50     file=`basename $file`
51     # find the line to this dataset and do further analysis
52     line=`grep $file $condorOutput/$book/$dataset/fileList.txt`
53     # find potential JSON file
54     export size=`echo $line | tr -s ' ' | cut -d ' ' -f 1`
55     # now run the download
56     echo "$script $dataDir/$book/$dataset/$file $target/$book/$dataset/$file"
57     $script $dataDir/$book/$dataset/$file $target/$book/$dataset/$file
58     done
59    
60     exit 0