From 00846a16085801d11786954ca3a027c0e8babee9 Mon Sep 17 00:00:00 2001 From: Maarten van Gompel Date: Mon, 2 Nov 2020 15:27:38 +0100 Subject: [PATCH] don't stumble over single quotes when sending SMS texts and replace double quotes with double single quotes to avoid trouble (a bit patchy) Signed-off-by: Maarten van Gompel --- scripts/modem/sxmo_modemsendsms.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/scripts/modem/sxmo_modemsendsms.sh b/scripts/modem/sxmo_modemsendsms.sh index e7d5cf1..7b1296d 100755 --- a/scripts/modem/sxmo_modemsendsms.sh +++ b/scripts/modem/sxmo_modemsendsms.sh @@ -34,8 +34,12 @@ else fi TEXTSIZE="${#TEXT}" +#mmcli doesn't appear to be able to interpret a proper escape +#mechanism, so we'll substitute double quotes for two single quotes +SAFE_TEXT=$(echo "$TEXT" | sed "s/\"/''/g") + SMSNO="$( - mmcli -m "$MODEM" --messaging-create-sms="text='$TEXT',number=$NUMBER" | + mmcli -m "$MODEM" --messaging-create-sms="text=\"$SAFE_TEXT\",number=$NUMBER" | grep -o "[0-9]*$" )" mmcli -s "${SMSNO}" --send || err "Couldn't send text message"