This script will check the inbox for a sms voucher (Format is *123443211234#) sent by me. it will forward this message to "132" (Namibia recharge number) delete the sms, receive the recharge message from the cell provider and mail it to me.
I set the script to run every 30 min, if there is no sms in the inbox it simply will not send anything as the message body is empty. Remember to change your email server settings, usb settings (for your modem) as well as your email address.
Most of this was provided by Base122
\
Set Receive Enabled, in case it was cleared by a router reboot
/tool sms set receive-enabled=yes;
delay 2;
:local smsMessage;
:local smsContent;
:log info "SMS to ReCharge script started";
delay 2;
loop through all the messages in the inbox
:foreach i in=[/tool sms inbox find] do={
:set smsMessage [/tool sms inbox get $i message];
:set smsContent "\nMessage: $smsMessage";
:log info $smsContent;
/tool sms send usb4 "132" message="$smsContent";
Now remove the SMS from the inbox
/tool sms inbox remove $i;
delay 10;
}
:local EmailAddress "123@jj.com";
:local smsPhone;
:local smsTimeStamp;
:local smsMessage;
:local smsContent;
Get System Identity
:local SystemID [/system identity get name];
:log info "SMS to Email script started";
delay 10;
loop through all the messages in the inbox
:foreach i in=[/tool sms inbox find] do={
:set smsPhone [/tool sms inbox get $i phone];
:set smsTimeStamp [/tool sms inbox get $i timestamp];
:set smsMessage [/tool sms inbox get $i message];
:set smsContent "Router ID: $SystemID\nSMS Received from: $smsPhone\nDate&Time: $smsTimeStamp\nMessage: $smsMessage";
:log info $smsContent;
/tool e-mail send tls=yes subject="$SystemID GSM Modem SMS Received" to=$EmailAddress body="$smsContent";
Now remove the SMS from the inbox
/tool sms inbox remove $i;
delay 10;
}
:log info "SMS to ReCharge script complete";