diff options
author | Shawn J. Goff <shawn7400@gmail.com> | 2013-02-15 15:18:31 -0500 |
---|---|---|
committer | Dan Williams <dcbw@redhat.com> | 2013-02-15 15:12:12 -0600 |
commit | d106b89b7ba8d055c96c682231dad6828b77fe95 (patch) | |
tree | 9272ab625359f5ed9d8d35679e8ddb8af73747d2 /utils | |
parent | 70b0d9fd9e2cec9a567c6c4516f056aa0ab1ae7f (diff) | |
download | external_libqmi-d106b89b7ba8d055c96c682231dad6828b77fe95.zip external_libqmi-d106b89b7ba8d055c96c682231dad6828b77fe95.tar.gz external_libqmi-d106b89b7ba8d055c96c682231dad6828b77fe95.tar.bz2 |
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).
Diffstat (limited to 'utils')
-rwxr-xr-x | utils/qmi-network | 6 |
1 files 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 |