answered
2014-01-22 14:09:32 +0200
Many thanks to Richard for confirming that the dbus-send should still work. I produced a bash script which, if placed in your /usr/local/bin directory will do the job for you. I've called the script qSMS.
You can get this from github at https://github.com/qururoland/qsms
Alternatively copy and paste the following:
#! /usr/bin/env bash
# Send an SMS message to one or more recipients via the commandline
# via SailfishOS
# Usage: qsms "The message" "+4412345678" "0207160 2888"...
# newfile is optional and will always have .jpg as a file type
# Check to see that at least one parameter has been passed
if [ $# -lt 2 ] || [ "$1" = "-h" ] || [ "$1" = "--help" ]
then
echo ""
echo "qSMS - a command line SMS tool"
echo "------------------------------"
echo ""
echo "Usage: qsms \"Your message\" \"tel no\" [\"another tel no\"]"
echo "This will send your message to each of the telephone numbers"
echo ""
echo "The message must be a single string. Use \n for new lines."
echo "Telephone numbers can be local (ie \"07768345678\") or"
echo "internationally formatted (ie \"+447768345678\")."
echo ""
echo "Roland Whitehead, http://quru.com, January 2014"
echo ""
echo ""
exit 1
fi
declare -i itsGood=1
function checkPattern {
# check the number $1 ($0 is alays the function name)
if [[ "$1" =~ "^\+?[0-9\ ]*$" ]]
then
return 0
else
return 1
fi
}
# Get the message
theMessage="$1"
# Clear out the first parameter
shift
# Loop through the rest of the parameters, checking each and sending it out
declare -i countSent=0
declare -i countFailed=0
while [ -n "$1" ]
do
theNumber="$1"
if checkPattern $theNumber
then
#echo "Sending $theMessage to $theNumber"
dbus-send --system --print-reply --dest=org.ofono /ril_0 org.ofono.MessageManager.SendMessage string:"$theNumber" string:"$theMessage"
countSent=$countSent+1
else
echo "The number $theNumber is incorrectly formatted."
countFailed=$countFailed+1
fi
shift
done
# Give feedback
if [ $countSent -gt 1 ]
then
goodMsg="$countSent messages sent"
else
if [ $countSent = 0 ]
then
goodMsg="No messages sent"
else
goodMsg="1 message sent"
fi
fi
if [ $countFailed = 1 ]
then
baddMsg="1 message failed"
else
badMsg="$countSent messages failed"
fi
if [ $countFailed -ne 0 ]
then
if [ $countSent -ne 0 ]
then
echo "$goodMsg. $badMsg."
exit 0
else
echo "$badMsg"
exit 0
fi
else
echo "$goodMsg."
exit 1
fi
Please don't be nasty - don't use it for spamming!
Sending SMS per ssh is kinda cool (in a very nerdy way) and porting SMSCON would be nice too.
PyroDevil ( 2014-01-22 00:36:32 +0200 )edit