aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Christian Hesse <mail@eworm.de>2024-03-12 17:59:37 +0100
committerGravatar Christian Hesse <mail@eworm.de>2024-03-12 18:02:47 +0100
commit24a65b21316e8cad7778ca2fb91defa69dd479c6 (patch)
tree99ae57ec67adf88c7437613a26d5c1f793e9d08f
parent92046bf0d506ee6e3d975f922afd6377f49b8939 (diff)
downloadrouteros-scripts-custom-24a65b21316e8cad7778ca2fb91defa69dd479c6.tar.gz
routeros-scripts-custom-24a65b21316e8cad7778ca2fb91defa69dd479c6.tar.zst
hello-world: use :do with on-error...
(... and skip the move into function.)
-rw-r--r--hello-world.rsc21
1 files changed, 12 insertions, 9 deletions
diff --git a/hello-world.rsc b/hello-world.rsc
index 1fbe6b4..ca125e7 100644
--- a/hello-world.rsc
+++ b/hello-world.rsc
@@ -6,16 +6,19 @@
# hello-world demo script
# https://git.eworm.de/cgit/routeros-scripts-custom/about/doc/hello-world.md
-:local 0 "hello-world";
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
-:global LogPrintExit2;
-:global ScriptFromTerminal;
-:global SendNotification2;
+:do {
+ :local ScriptName [ :jobname ];
-:if ([ $ScriptFromTerminal $0 ] = true) do={
- $LogPrintExit2 info $0 ("Hello world!") false;
-} else={
- $SendNotification2 ({ origin=$0; subject="Hello..."; message="... world!" });
-}
+ :global LogPrintExit2;
+ :global ScriptFromTerminal;
+ :global SendNotification2;
+
+ :if ([ $ScriptFromTerminal $ScriptName ] = true) do={
+ $LogPrintExit2 info $ScriptName ("Hello world!") false;
+ } else={
+ $SendNotification2 ({ origin=$ScriptName; subject="Hello..."; message="... world!" });
+ }
+} on-error={ }