Hello,
I kindly ask for advice regarding the SMS reply configuration. I have set the “SMS rule configuration” to “Execute custom script”, and I need to read the result of a PHP script (executing the shell command curl -s http://192.168.10.30/read.php returns a numeric value), and send this returned value as an SMS to the sender of the original SMS command.
How should I set the variables in the command api post /messages/actions/send '{"data": {"number": "+370XXXXXX", "message": "Hello", "modem": "2-1"} }' to replace the phone number and message text dynamically?
The full script could look like this:
#!/bin/sh
PHONE="$1"
RESPONSE=$(curl -s http://192.168.10.30/read.php)
api post /messages/actions/send…
#!/bin/sh
PHONE="+420xxxxxxxxx"
RESPONSE=$(curl -s --max-time 5 192.168.10.30/read.php)
if [ -n "$RESPONSE" ]; then
MESSAGE="$RESPONSE"
else
MESSAGE="Read error"
fi
/sbin/api post /messages/actions/send "{\"data\": {\"number\": \"$PHONE\", \"message\": \"$MESSAGE\", \"modem\": \"1-1.4\"}}"
If I enter a script with a fixed number and run the script via an SMS command, it will execute and send the SMS. However, the variable for the phone number, $sms_sender, and $1 do not work.
Do you have any idea how to pass the sender’s number into the variable PHONE?