Last active
December 16, 2016 22:45
-
-
Save shreyb/0e60afe357d9274fb59bca4ec631a8d8 to your computer and use it in GitHub Desktop.
Put a VO Correction Record into GRACC
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
function checklength { | |
if [[ ${#1} -ne 0 ]]; | |
then | |
VARCOUNT=$((VARCOUNT+1)) | |
fi | |
} | |
CURTIME=`date +%s` | |
# FILENAME is file with pipe-delimited rows with VOName, ReportableVOName, and CorrectedVOName in each row | |
FILENAME=VOFile.txt | |
while IFS='|' read -r VO RVO CVO; | |
do | |
VARCOUNT=0 | |
for VAR in $VO $RVO $CVO; | |
do | |
checklength "$VAR" | |
done | |
if [[ $VARCOUNT -eq 3 ]]; then | |
RAWJSON="{ \"VOName\": \"$VO\", \"ReportableVOName\": \"$RVO\", \"CorrectedVOName\": \"$CVO\", \"@timestamp\":\"$CURTIME\", \"type\":\"vo\" } " | |
PUTCMD="curl -XPOST \"http://localhost:9200/gracc.corrections-0/vo/\" -d '$RAWJSON'" | |
#echo $RAWJSON | |
echo $PUTCMD | |
#eval $PUTCMD | |
else | |
echo "Bad line" | |
continue | |
fi | |
done < $FILENAME | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment