I updated my RUT951 from firmware 7.11.3 to 7.16.3. This has broken a custom script that uses parameters. The symptom is that shell parameters $* returns an empty string instead of the words in the SMS after the initial keyword used to trigger the custom script rule. (I am also using $SMS_FROM to access the phone number that sent the SMS, and this still works.) Here is the text of the script, for information:
where hostname is the local hostname of a Raspberry Pi 4, and topic is the Mosquitto topic. Code on the Pi 4 needs to interpret the $* parameters (several actions are possible, depending on the words used). The code on the Pi4 reports an empty string where it should have received the words in the SMS message.
I don’t know where the script is stored. I entered it into the RUT951 WebUI under SMS Utilities/Custom Script. Apologies for not making this clear in my original post. I don’t read the SMS content. The SMS Utilities passes the text of the SMS as parameters to the custom script. These are something like: keyword heater on. The keyword triggers the custom script, the second and third are passed as parameters to the custom script using $* as in my original post, then passed on as a MQTT message to code running on my Raspberry Pi 4, which interprets the parameters, and acts upon them.
Apologies for the delay, and thanks for your clarification, it’s abit clearer now that you’re using SMS Utilities rules to trigger a custom script that publishes to your MQTT broker.
Could you please clarify a few points:
How many SMS Utilities rules do you have configured?
Could you provide a screenshot of one of these rules with script for clarity?
Is the 3rd party mosquitto-client package actually installed on the router?
For testing, you could try switching the shell used to execute the custom script (from sh to ash or bash).
Could you also clarify what parameters are passed to the script, just the keyword from the SMS, or additional text as well?
Answers as far as possible. For security I have disabled remote access to the router, I can only access it by SSH and WebUi when connected physically to the LAN.
There are about 5 SMS Utilitites rules configured. I can’t recall exactly.
I can’t provide a screenshort until my next visit (the router is installed on a boat).
The MQTT client is installed from opkg. For info, each time I upgrade the firmware I have to reinstall this package, as the firmware upgrade removes it.
Noted about the shell. I can certainly try bash when I am able to connect.
The script receives all the words in the SMS message, whatever they are. This is how the SMS Utilities custom rule works I think, using $ passes the full text of the SMS message broken into tokens. The script passes them all to the MQTT broker and the Ruby code that receives the message processes the words. At least that was before the firmware upgrade. After the upgrade, the $* fails to pass the parameters.
The fault symptoms are unchanged with this firmware. $SMS_FROM $* in the custom script produces empty strings, not the sending phone number or the text in the SMS message received. I had to reinstall the 07.11.3 firmware, as I cannot leave the router with this custom script inoperable. Replacing the firmware and reinstalling mosquitto client takes time, and reverting to the previous firmware takes more time. I’ll have another go another day, I should have tried the change from ash to bash, while I had the latest firmware installed.
Update again. I have narrowed the issue to a specific firmware release, and I have given below a minimal test case, which does not require the mosquitto client.
Firmware version 07.15 is the earliest which exhibits the problem.
Firmware version 07.14.3 does not exhibit the problem. I am now running this version, so at least I have been able to move my router on from 07.11.3 to a more recent version.
The minimal test is this: a custom script SMS Utilities rule, so that sending the SMS message “test alpha bravo” results in the file /tmp/parameters on the router being written with the text “xxxxxyyyyyyy alpha bravo” where xxxxxyyyyyyyy is the sender’s phone number. “test” is the keyword that triggers the SMS rule. alpha bravo are arbitrary words, of arbitrary number.
The script reads as follows:
#!/bin/sh
echo $SMS_FROM $* > /tmp/parameters.txt
The problem is that from firmware 07.15 onwards the $* in the script returns a blank string, whereas in earlier firmware versions it contains the rest of the SMS message after the keyword “test”, parsed into one token/string per script argument.
Thank you for the performed tests and sharing a feedback here.
After performing deeper internal testing and debugging script on our side, I can confirm what you have already observed:
From firmware 07.15 onward, the SMS Utilities “Custom Script” rule no longer passes the SMS text to the script.
Only the variable SMS_FROM is provided.
The positional arguments ($*, $1, $2, …) and message text variables are no longer populated.
This most likely strongly to be caused by a firmware regression introduced from FW 07.15.
If you would like, I can forward this discrepancy to our R&D team so they can analyze the regression and evaluate whether a fix or a workaround can be suggested.
The latest FW version 07.20 has this entry in the changelog for RUT9xx devices:
SMS Utilities: fixed script action execution when arguments are provided
This may be a fix for the problem, but I have no confirmation about this, and I am not able to visit the site where the router is installed to try this firmware version at the moment.