Page 1 of 1

Running script via API does not set global variable

Posted: Thu Aug 29, 2019 9:53 am
by ShyLion
Hello. I'm strugling with task of getting lte info via API.
I've come with solution where global var is set via scheduled script and i fetch it's value with API call.
That is not perfect way, because information is obsolete by the time i fetch it and what is more important - it is absent when device is just rebooted and came online, but scheduled script didn't run yet.
Now to the subject.
I've tried to run mentioned script via API call, just vefore fetching it's result:
mktik_api_cmd -i 10.2.1.4 /system/script/run =.id=lteinfo
It's run count is increased, but variable value does not change!

Script itself:
[busadmin@r00004] > system script print detail where name="lteinfo"
Flags: I - invalid 
 0   name="lteinfo" owner="busadmin" policy=ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon dont-require-permissions=no last-started=aug/29/2019 11:49:02 run-count=19 
     source=:global lteinfo nointerface; if ([/interface lte print count-only] > 0) do={ :local li [/interface lte info lte1 once as-value]; :set lteinfo ("atech=".$li->"access-
       technology".";cop=".$li->"current-operator".";rs=".$li->"registration-status".";rssi=".$li->"rssi".";rsrp=".$li->"rsrp".";su=".$li->"session-uptime"); }; 

Formatted:
:global lteinfo nointerface;
:if ([/interface lte print count-only] > 0) do={
  :local li [/interface lte info lte1 once as-value];
  :set lteinfo ("atech=".$li->"access-technology".";cop=".$li->"current-operator".";rs=".$li->"registration-status".";rssi=".$li->"rssi".";rsrp=".$li->"rsrp".";su=".$li->"session-uptime");
}; 

What am i doing wrong?

Re: Running script via API does not set global variable

Posted: Thu Aug 29, 2019 10:52 am
by mrz
does it work with dont-require-permissions=yes?

Re: Running script via API does not set global variable

Posted: Thu Aug 29, 2019 10:56 am
by ShyLion
does it work with dont-require-permissions=yes?
It only affects running script with non-owner user. Nothing changes in regard of problem, i tried.

Maybe i'm going wrong way? Maybe i can get result of [/some non api command] via script itself?

Re: Running script via API does not set global variable

Posted: Thu Aug 29, 2019 12:03 pm
by ShyLion
Damn it!
Script, runnig via API, does not have access to "/interface lte info lte1 once as-value"
WTF?