From 5dda6d810d128b56cd22328e16897cb40f3fbe15 Mon Sep 17 00:00:00 2001 From: Jonas Smedegaard Date: Sat, 10 Oct 2015 22:48:14 +0200 Subject: Parse response reliably, and handle no-op (response code 1) separate from failure. --- localbrotherfwfetch | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) (limited to 'localbrotherfwfetch') diff --git a/localbrotherfwfetch b/localbrotherfwfetch index 3ef554c..ff7e4bb 100755 --- a/localbrotherfwfetch +++ b/localbrotherfwfetch @@ -38,22 +38,23 @@ do echo -n '121' >> request.xml curl -X POST -d @request.xml https://firmverup.brother.co.jp/kne_bh7_update_nt_ssl/ifax2.asmx/fileUpdate -H "Content-Type:text/xml" --sslv3 -o response.xml -s - valid=`grep "0" response.xml` - if [ -n "$valid" ] - then + case $(xmllint --xpath '/RESPONSEINFO/FIRMUPDATEINFO/VERSIONCHECK/text()' response.xml) in + 0) echo "--- request (name=$name, spec=$spec, firm=$firmid, version=$version) ---" cat request.xml | xmllint --format - echo "--- response ---" cat response.xml | xmllint --format - - else - partial=`grep "2" response.xml` - if [ -n "$partial" ] - then - echo "-- the request is partially incomplete (name=$name, spec=$spec, firm=$firmid, version=$version) --" - else - echo "-- the request is invalid (name=$name, spec=$spec, firm=$firmid, version=$version) --" - fi - fi + ;; + 1) + echo "-- no firmware update available (name=$name, spec=$spec, firm=$firmid, version=$version) --" + ;; + 2) + echo "-- the request is partially incomplete (name=$name, spec=$spec, firm=$firmid, version=$version) --" + ;; + *) + echo "-- the request is invalid (name=$name, spec=$spec, firm=$firmid, version=$version) --" + ;; + esac rm request.xml response.xml done done -- cgit v1.2.3