Community discussions

MUM Europe 2020
just joined
Topic Author
Posts: 3
Joined: Sat Oct 06, 2018 4:51 pm

Script not working if scheduled

Sat Oct 06, 2018 5:28 pm

I have written two scripts, one to parse SMS inbox for certain keyword, the other get called by the inbox scan script if the SMS text matches (to get LTE status information and return it to the original SMS requestor).

The scripts generally works fine if manually triggered from command line via /system script run, but not when scheduled.
Via debug printing I found out that the status script is stopping at the line "/interface lte info [find where name="lte1"] once do={" if scheduled.

So my questions are:
* Why is the script not working if scheduled?
* Is there a way to use the official SMS script functionality for this? I want to reply to the original SMS sender, is that SMS senders address available?
 1   name="status" owner="admin" policy=read,sensitive dont-require-permissions=no last-started=oct/06/2018 16:16:53 run-count=567 source=
       :global smsPhone
       :local co
       :local at
       :local su
       :local cc
       :local tx [/interface get lte1 tx-byte]
       :local rx [/interface get lte1 rx-byte]
       /interface lte info [find where name="lte1"] once do={
         :set at $"access-technology"
         :set co $"current-operator"
         :set su $"session-uptime"
         :set cc $"current-cellid"
         :if ( [:len $smsPhone] > 0 ) do={
           :log info "[SMS] Status SMS sent to $smsPhone: $co: $at, up=$su, rsrp=$rsrp, sinr=$sinr, lac=$lac, cellid=$cc"
           :do {
             /tool sms send lte1 "$smsPhone" message="$co: $at, up=$su, rsrp=$rsrp, sinr=$sinr, lac=$lac, cellid=$cc"
           } on-error={ :log info "[SCRIPT] status script SMS send error" }
         } else={
           :log info "[LTE] $co: $at, up=$su, rsrp=$rsrp, sinr=$sinr, lac=$lac, cellid=$cc, tx=$tx, rx=$rx"
       :log debug "[SCRIPT] status script finished"

 2   name="check-sms-messages" owner="admin" policy=read,sensitive dont-require-permissions=yes last-started=oct/06/2018 16:27:00 run-count=610
       :local curDate [/system clock get date]
       :local curTime [/system clock get time]
       :global smsPhone nil
       :local smsTimestamp
       :local smsMessage
       :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];
         :log debug "[SMS] $1 from=$smsPhone, ts=$smsTimestamp, msg=$smsMessage"
         :if ( $smsMessage = "status <PASSWORD>" ) do={
           :log info "[SMS] Status requested by $smsPhone"
           /system script run [/system script find name=status]
           /tool sms inbox remove $i
         :if ( $smsMessage = "reboot <PASSWORD>" ) do={
           :log info "[SMS] Reboot requested by $smsPhone"
           /tool sms send lte1 "$smsPhone" message="Reboot bestaetigt"
           /tool sms inbox remove $i
           /system reboot
* Routerboard:
/system routerboard> print 
                ;;; Warning: cpu not running at default frequency
       routerboard: yes
             model: RBSXTR
     serial-number: 9983XXXXXXX
     firmware-type: qca9531L
  factory-firmware: 6.41.3
  current-firmware: 6.43.2
  upgrade-firmware: 6.43.2

* Also this wont work if scheduled (no error printed, but script stops there)
:global lteStat ([/interface lte info [find where name="lte1"] once as-value])  
just joined
Topic Author
Posts: 3
Joined: Sat Oct 06, 2018 4:51 pm

Re: Script not working if scheduled  [SOLVED]

Sun Oct 07, 2018 3:54 pm

Problem is solved. This was related to the permissions given to the Scheduler. I simply gave it all permissions - I didnt find out which one exactly was needed.

Who is online

Users browsing this forum: No registered users and 12 guests