Comment 3 for bug 569488

Revision history for this message
Moritz Naumann (mnaumann) wrote :

This very dirty bash snippet works (currently):

#!/bin/sh
JSON=$(wget -qO- 'http://downloadcenter.intel.com/JSONDataProvider.aspx?sort=Date&sortDir=descending&Hits=1&keyword="Linux microcode "&lang=eng&refresh=filters&dataType=json')
VERSION=$(echo $JSON | sed 's/^.*,"version":"\([^"]*\).*$/\1/')
DOWNLOADID=$(echo $JSON |sed 's/^.*,"downloadid":"\([^"]*\).*$/\1/')
wget "http://downloadmirror.intel.com/${DOWNLOADID}/eng/microcode-${VERSION}.tgz"

It's obviously incorrect to run sed on serialized data, though. And this example will fail on marginal changes.

Better ways of parsing JSON (such as using python) are discussed at
http://stackoverflow.com/questions/1955505/parsing-json-with-sed-and-awk