From d106b89b7ba8d055c96c682231dad6828b77fe95 Mon Sep 17 00:00:00 2001 From: "Shawn J. Goff" Date: Fri, 15 Feb 2013 15:18:31 -0500 Subject: [PATCH] qmi-network: Fix grabbing output from lines with spaces The qmi-network script used awk with a field separator of ":". The output looked like key: 'value'. The second field in this case includes a space at the beginning. This was making the 'status' command fail. Now, we account for the space. It is now also not dependent on awk (this can matter on embedded systems). --- utils/qmi-network | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/utils/qmi-network b/utils/qmi-network index b82fa85..1129aa4 100755 --- a/utils/qmi-network +++ b/utils/qmi-network @@ -119,7 +119,7 @@ start_network () # Save the new CID if we didn't use any before if [ "x$CID" = "x" ]; then - CID=`echo "$START_NETWORK_OUT" | grep CID | sed "s/'//g" | awk 'BEGIN { FS = ":" } ; { print $2 }'` + CID=`echo "$START_NETWORK_OUT" | sed -n "s/.*CID.*'\(.*\)'.*/\1/p"` if [ "x$CID" = "x" ]; then echo "error: network start failed, client not allocated" 1>&2 exit 1 @@ -128,7 +128,7 @@ start_network () fi fi - PDH=`echo "$START_NETWORK_OUT" | grep handle | sed "s/'//g" | awk 'BEGIN { FS = ":" } ; { print $2 }'` + PDH=`echo "$START_NETWORK_OUT" | sed -n "s/.*handle.*'\(.*\)'.*/\1/p"` if [ "x$PDH" = "x" ]; then echo "error: network start failed, no packet data handle" 1>&2 # Cleanup the client @@ -187,7 +187,7 @@ packet_service_status () STATUS_OUT=`$STATUS_CMD` fi - CONN=`echo "$STATUS_OUT" | grep "Connection status" | sed "s/'//g" | awk 'BEGIN { FS = ":" } ; { print $2 }'` + CONN=`echo "$STATUS_OUT" | sed -n "s/.*Connection status:.*'\(.*\)'.*/\1/p"` if [ "x$CONN" = "x" ]; then echo "error: couldn't get packet service status" 1>&2 exit 2