Global var empty when scripting, but exist in terminal.

Hello!
I have a script to grab some LTE data. And result of this script is var. And I can see it int “:env print” or “:put $var”. But I want to ask my SNMP this var with this method https://wiki.mikrotik.com/wiki/Manual:SNMP#Runing_scripts_with_GET. And I’m stuck. Don’t understand how to output global var in script.
Script to make var $at:

/system script
add dont-require-permissions=no name=at owner=admin policy=\
    ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon source=\
    "/interface lte info lte1 once do={:global at \$\"access-technology\" } \r\
    \n"

Script to output it:

/system script
add dont-require-permissions=no name=at_result owner=admin policy=\
    ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon source=":put \$at"

And this is result:

[admin@Mikrotik_24] > /system script run at
           pin-status: ok
  registration-status: registered
        functionality: full
         manufacturer: "MikroTik"
                model: "R11e-LTE"
             revision: "MikroTik_CP_2.160.000_v008"
     current-operator: MTS
                  psc: 295
                  lac: 5205
       current-cellid: 241903616
    access-technology: 3G
       session-uptime: 21h3m18s
                 imei: 355654090621868
                 imsi: 250016652966098
                 uicc: 89701011266529660988
               earfcn: 10762
                 ecno: 0dB
                 rssi: -95dBm
 [admin@Mikrotik_24] > :environment print   
at="3G"

[admin@Mikrotik_24] > :put $at 
3G

But, how to output it via script I don’t know.

[admin@Mikrotik_24] > /system script run at_result     

[admin@Mikrotik_24] >

Here is two way to set a global variable:

{
:global test
set $test "my data"
}



{
:global test "my data"
}

This will not work in a script to get the variable in a script, may work from terminal:

{
:put $test
}

You need to declare the variable in the script so it knows about it, so correctly:

{
:global test
:put $test
}

Thanks a lot Jotne!
Yes, you are right.
And via SNMP I can see this var even with my wrong {:put $var} in script.

snmpget -c public -v 2c 192.168.88.1 1.3.6.1.4.1.14988.1.1.18.1.1.2.2
SNMPv2-SMI::enterprises.14988.1.1.18.1.1.2.3 = STRING: "Evolved 3G (LTE)"

Maybe you will be insterested in Logging changes at LTE Parametrs to know if the Tower or Sector Antenna was change etc..
Watch LTE parameters: http://forum.mikrotik.com/t/r11e-lte6-2ca-not-staying-connected/136004/22