ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitProd/Processing/bin/downloadFiles.sh
Revision: 1.5
Committed: Tue Feb 28 11:54:35 2012 UTC (13 years, 2 months ago) by paus
Content type: application/x-sh
Branch: MAIN
CVS Tags: Mit_032, Mit_031, Mit_030, Mit_029c, Mit_029b, Mit_030_pre1, Mit_029a, Mit_029, Mit_029_pre1, Mit_028a, Mit_028, Mit_027a, Mit_027, Mit_026, Mit_025e, Mit_025d, HEAD
Changes since 1.4: +5 -3 lines
Log Message:
Last updates.

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