Страница 1 из 1
переменные и функции для скриптов из скрипта
Добавлено: 08 дек 2021, 13:08
-13-
Добрый час, всем!
Есть скрипт, который стартует один раз, при старте системы.
:global botID "botXXXxxxXXX";
:global myChatID "YYYyyyYYY";
:global syName [/system identity get name];
:global tgSend [:parse [/system script get SendToBot source]];
:global cuDate do={return ([/system clock get date]." - ".[/system clock get time])};
:global cuUptime do={return [/system resource get uptime]};
:global cuIP do={return [/ip dhcp-client get [find comment=fromDHCPaddr] addr]};
:global cuGW do={return [/ip dhcp-client get [find comment=fromDHCPaddr] gateway]};
:global VPNtoOffice1 [/interface l2tp-client get [find comment=VPN_to_Office1] name];
:global cuVPNtoOffice1 do={global VPNtoOffice1 [return ([/interface l2tp-client monitor [find comment=VPN_to_Office1] once as-value]->"status")]};
:global VPNtoOffice2 [/interface l2tp-client get [find comment=VPN_to_Office2] name];
:global cuVPNtoOffice2 do={global VPNtoOffice2 [return ([/interface l2tp-client monitor [find comment=VPN_to_Office2] once as-value]->"status")]};
:global VPNtoOffice3 [/interface l2tp-client get [find comment=VPN_to_Office3] name];
:global cuVPNtoOffice3 do={global VPNtoOffice3 [return ([/interface l2tp-client monitor [find comment=VPN_to_Office3] once as-value]->"status")]};
Вопрос:
Как сделать чтоб скрипты брали переменные и функции из текста скрипта, чтоб не объявлять их глобальными?
По аналогии вот этой функции:
:global tgSend [:parse [/system script get SendToBot source]];
Один из скриптов который оперирует глобальными переменными и функциями
:global syName;
:global tgSend;
:global cuDate;
:global VPNtoOffice2
/interface l2tp-client set $VPNtoOffice2 disable=no
:local Text "\"$syName\":%0A$[$cuDate]%0AVPN: wait log message"
$tgSend Text=$Text;