SQLITE | BASH | handle ‘database locked’

function do_sql { DB=”$1″ shift test -r “$DBDIR/$DB” if [ $? -ne 0 ]; then write2log “Creating DB $DB” create_db “$DB” fi if [ “x$@” == “x” ]; then return 1; fi LOOP=1;MAXLOOP=10 while true;do $SQLITE “$DBDIR/$DB” “$@” 2>/dev/null && return 0 LOOP=$(( $LOOP + 1 )) RD=”0.$(( ( RANDOM % 9 ) + 1 […]

BASH vs. JSON :)

curl -s “https://www.pegelonline.wsv.de/webservices/rest-api/v2/stations.json?includeTimeseries=true&includeCurrentMeasurement=true”| jq -j –tab ‘.[] | select( ( .timeseries[0].currentMeasurement.stateMnwMhw==”low” or .timeseries[0].currentMeasurement.stateMnwMhw==”high” ) and .timeseries[0].shortname==”W” ) | [ .number, .water.longname, .longname, .latitude, .longitude, .timeseries[0].currentMeasurement.stateMnwMhw, .timeseries[0].currentMeasurement.trend, .timeseries[0].currentMeasurement.value ] | “\(.[0])|\(.[1])|\(.[2])|\(.[3])|\(.[4])|\(.[5])|\(.[6])|\(.[7])\n”‘)

bash | xml | parsing

GENTOO: emerge libxml2 test -r $XMLFILE if [ $? -eq 0 ]; then     A_XML=($(xmllint –xpath “//aaaa/bbbb/@cccc” $XMLFILE ))     for CXML in “${A_XML[@]}”; do     xmllint –xpath “//aaaa/bbbb[@$CXML]” $XMLFILE | grep ‘test for something’ > /dev/null     if [ $? -eq 0 ]; then         xmllint –xpath “//aaaa/bbbb[@$CXML]/dddd” $XMLFILE | sed ‘s|]*.||g’    […]