ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitProd/Processing/bin/downloadFiles.sh
Revision: 1.1
Committed: Sun Dec 5 01:01:20 2010 UTC (14 years, 5 months ago) by paus
Content type: application/x-sh
Branch: MAIN
CVS Tags: Mit_017
Log Message:
Next iteration with improved downloading tool.

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