I can send text messages by SMS using the command:
$ /usr/share/ofono/scripts/send-sms /ril_0 07123456789 "iorem ipsum est" 0
/ril_0 is the SIM card/modem,
07123456789 is the telephone number,
"iorem ipsum est" is the text to be sent and the last
0 is (I think) a boolean determining whether or not the script will request a delivery report.
This works fine, and produces the output:
Send message using modem /ril_0 ... /ril_0/message_20C76858222F2CDF61342FC317BF53AC4B763441
However, this doesn't seem to work:
$ echo '"iorem ipsum est"' > textfile $ /usr/share/ofono/scripts/send-sms /ril_0 07123456789 $(cat textfile) 0
I tried a few permutations, backticks and so forth; none of them work and they all produce output like this:
Send message using modem /ril_1 ... Traceback (most recent call last): File "/usr/share/ofono/scripts/send-sms", line 31, in <module> mm.SetProperty("UseDeliveryReports", dbus.Boolean(int(sys.argv))) ValueError: invalid literal for int() with base 10: '"iorem'
/ril_1 is where the second SIM card would be (if there were one), and I guess the rest is a stack trace?
For what it's worth, this works fine:
$ echo '"iorem"' > textfile $ /usr/share/ofono/scripts/send-sms /ril_0 07123456789 $(cat textfile) 0
So I guess the problem lies in the way
$() handles output containing whitespace?
I've pasted the contents of
/usr/share/ofono/scripts/send-sms to http://pastebin.com/u8gHMc5R (and of course the source is available to download from Ubuntu, here http://packages.ubuntu.com/en/vivid/ofono-scripts).
I don't really want to mess with the original Python script (even if I knew any Python, which I don't!), but if there isn't a shell solution that I don't know (something using pipes or xargs, maybe?) I wouldn't be against the idea of another script which makes use of the original one, or something.
My system is a BQ Aquaris running 15.04 (r23). In case it makes a difference somehow, I'm running all these commands via ssh rather than typing them into the phone.
Any help much appreciated. Oh, and if I should be posting this somewhere else, for instance on Stack Overflow or something because of all the Python, please do let me know!