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

# Content
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 pid=$1; shift
16 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 echo " file range : $first -- $last"
26 echo " pid : $pid"
27
28 mkdir -p $condorOutput/$book/$dataset
29 script=`which downloadFile.sh`
30
31 # make sure the request is good
32 nFiles=`wc -l $condorOutput/$book/$dataset/fileList.$pid.txt | cut -d ' ' -f 1`
33 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 fList=`head -$last $condorOutput/$book/$dataset/fileList.$pid.txt | tail -$nFilesPerJob | cut -d' ' -f 2`
42
43 echo LIST $fList
44
45 # spread the jobs out by a bit
46 #sleep $first
47
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 line=`grep $file $condorOutput/$book/$dataset/fileList.$pid.txt`
54 # 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