Alter file name and JSON structure in transfer-data.sh

This commit is contained in:
Kai S. K. Engelbart 2021-03-12 14:37:36 +01:00
parent 179622ca2f
commit 830414d37c
Signed by: kske
GPG Key ID: 8BEB13EC5DF7EF13

View File

@ -5,13 +5,15 @@ TTD="10"
KEY="ZGVmaW5tYUB0MzhiYmNjZDE2MjE3NDViODgxMTk5ZGI2ZWQzZGFiNmE6RGVGaW5NYWNoZW4yMDIwIQ==" KEY="ZGVmaW5tYUB0MzhiYmNjZDE2MjE3NDViODgxMTk5ZGI2ZWQzZGFiNmE6RGVGaW5NYWNoZW4yMDIwIQ=="
# Build name # Build name
NAME=${1##*/} # Basename of file with the last dot replaced by a slash and .DPT extension
NAME=$(basename $1)
NAME="${NAME%.*}_${NAME##*.}.DPT"
# Build body # Build body
JSON="{\"$NAME\": [" JSON="{\"filename\":\"$NAME\",\"dpt\":["
while read LINE while read LINE
do do
JSON+="[${LINE%,*}, ${LINE#*,}], " JSON+="[\"${LINE%,*}\",\"${LINE#*,}\"], "
done < $1 done < $1
JSON=${JSON::-2} JSON=${JSON::-2}
JSON+=']}' JSON+=']}'