1

I can send text messages by SMS using the command:

$ /usr/share/ofono/scripts/send-sms /ril_0 07123456789 "iorem ipsum est" 0

Where /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[3])))
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!

1 Answer 1

0

Use double quotes to wrap the command substitution. Also either use single quotes or use double quotes in the echo command, there's no need to use both:

echo 'iorem ipsum est' > textfile
/usr/share/ofono/scripts/send-sms /ril_0 07123456789 "$(cat textfile)" 0
1
  • I think he was thinking both would mean $(cat textfile) would yield "foo bar" instead of \"foo bar\" Commented Jul 11, 2015 at 15:29

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .