Can somebody explain how this script works?
Posted: Sun Jan 08, 2023 1:48 pm
I was testing some script to allow variable function name. And suddenly found very confusing result for this short script. Tested on ROS 6.49 and 7.6. Can someone explain how it works?
Output:
I suppose this is a bug, because another variant is more interesting:
Output:
Code: Select all
:local cookie "someName";
:local cookieCode do={
:put "TestIt";
/system routerboard print;
};
[[:parse (":global ".$cookie)]];
[[:parse (":global ".$cookie."; :set \$".$cookie." (\"\");")]];
/system script environment remove [find where name=$cookie];
Code: Select all
TestIt
routerboard: yes
board-name: hAP ac
model: RB962UiGS-5HacT2HnT
serial-number: XXXXXXXXXXX
firmware-type: qca9550L
factory-firmware: 6.43.10
current-firmware: 7.6
upgrade-firmware: 7.6
Code: Select all
:local cookie "someName";
:local cookieCode do={
:put "TestIt";
/system routerboard print;
};
:local cookieCode2 do={
:put "TestIt2";
/system resource print;
};
[[:parse (":global ".$cookie)]];
[[:parse (":global ".$cookie."; :set \$".$cookie." (\"\");")]];
/system script environment remove [find where name=$cookie];
Code: Select all
TestIt
routerboard: yes
board-name: hAP ac
model: RB962UiGS-5HacT2HnT
serial-number: XXXXXXXXX
firmware-type: qca9550L
factory-firmware: 6.43.10
current-firmware: 7.6
upgrade-firmware: 7.6
TestIt2
uptime: 2w6d4h21m51s
version: 7.6 (stable)
build-time: Oct/17/2022 10:55:40
factory-software: 6.43.10
free-memory: 63.7MiB
total-memory: 128.0MiB
cpu: MIPS 74Kc V5.0
cpu-count: 1
cpu-frequency: 720MHz
cpu-load: 18%
free-hdd-space: 512.0KiB
total-hdd-space: 16.0MiB
write-sect-since-reboot: 120848
write-sect-total: 1554295
bad-blocks: 0%
architecture-name: mipsbe
board-name: hAP ac
platform: MikroTik