Jq stuff

From SoftwareGuy
Revision as of 14:36, 11 May 2023 by Mark (talk | contribs)
Jump to navigation Jump to search

Using jq

Parsing

Command to return the id number of the last scan:

cnt=$(jq '.lastVehicleRecord.scans | length' heartbeat)

Fancy way to find the scanId of a selected system via bash and jq

if [ -z $1 ]; then whichIE="uvx"; else whichIE=$1; fi
printf ".lastVehicleRecord.scans[] | select(.type | endswith(\""$whichIE"\"))\n" > parms.jq

wget -qO heartbeat http://$ip/heartbeat
cnt=$(jq '.lastVehicleRecord.scans | length' heartbeat)

id=$(jq -f parms.jq heartbeat | jq '.id')
if [ ! -z $id ]; then
    wget -qO $id.orig.tiff http://$ip/requestImage/?scanId=$id
fi

Tiffinfo parsing

Parsing examples of .tiff files extracing meta data from the headers.

tiffinfo 2023-05-07\ 13_57_17_evx_left_3845.tiff | grep 65001 | sed 's/  Tag 65001: //' | sed 's/\\//'g | jq

tiffinfo 2023-05-07\ 13_57_17_evx_left_3845.tiff | grep 65001 | sed 's/  Tag 65001: //' | sed 's/\\//'g | jq '.timestamp'

tiffinfo 2023-05-07\ 13_57_17_evx_left_3845.tiff | grep 65001 | sed 's/  Tag 65001: //' | sed 's/\\//'g | jq '.renderData.type'