All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
sbndpoms_metadata_extractor.sh
Go to the documentation of this file.
1 #!/bin/bash
2 
3 
4 #The metadata creation scheme makes a json file as part of the job running. We can't pass the name of the json to the extractor so we will need to assume a json name
5 #The assumed json name is hist_STAGE.root.json
6 #The input file has been uniquely renamed by the time this script is called so we need to use some regex magic (thanks Marc!) to reconstruct the original json name
7 
9 JSONFILE=`echo $INPUTFILE | sed -re 's/-[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}//'`
10 JSONFILE="${JSONFILE}.json"
11 
12 
13 #We need to remove the braces at the end of the file as we are going to append more information
14 sed -i '$ d' $JSONFILE
15 #We also need to add a comma to the end of the last line now that we are going to add more line
16 sed -i '$ s/$/\,/g' $JSONFILE
17 
18 #Add the filename back in
19 sed -i "\$a \"file_name\": \"$(basename $INPUTFILE)\"," $JSONFILE
20 #Add the file size
21 FILESIZE=`wc -c < $INPUTFILE`
22 sed -i "\$a \"file_size\": \"$FILESIZE\"," $JSONFILE
23 
24 
25 #calculate checksum
26 CHECKSUM=`samweb -e sbnd file-checksum $INPUTFILE`
27 sed -i "\$a \"checksum\": $CHECKSUM," $JSONFILE
28 
29 
30 #Make sure that the last entry does not have a comma at the end of its line
31 sed -i '$ s/,//g' $JSONFILE
32 #
33 ##re-add the closing brace
34 sed -i '$a }' $JSONFILE
35 
36 #Dump the json to std::out, needed for metadata_extractor
37 cat $JSONFILE
* file
Definition: file_to_url.sh:69
then echo fcl sbnd_project sbnd_project sbnd_project sbnd_project production production checksum
do i e
stream1 can override from command line with o or output services user sbnd