mirror of
https://git.eworm.de/cgit/routeros-scripts
synced 2025-07-10 18:14:27 +02:00
global-functions: introduce $ScriptFromTerminal
Checking whether or not started from terminal is tricky... We have to find the job for the script, find its top most parent and get its type.
This commit is contained in:
parent
bccdb47fde
commit
ebd5ff9bfe
1 changed files with 18 additions and 0 deletions
|
@ -243,6 +243,24 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# check if script is run from terminal
|
||||||
|
:global ScriptFromTerminal do={
|
||||||
|
:local Script [ :tostr $1 ];
|
||||||
|
|
||||||
|
:foreach Job in=[ / system script job find where script=$Script ] do={
|
||||||
|
:set Job [ / system script job get $Job ];
|
||||||
|
:while ([ :typeof ($Job->"parent") ] = "id") do={
|
||||||
|
:set Job [ / system script job get [ find where .id=($Job->"parent") ] ];
|
||||||
|
}
|
||||||
|
:if (($Job->"type") = "login") do={
|
||||||
|
:log debug ("Script " . $Script . " started from terminal.");
|
||||||
|
:return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
:return false;
|
||||||
|
}
|
||||||
|
|
||||||
# wait for file to be available
|
# wait for file to be available
|
||||||
:global WaitForFile do={
|
:global WaitForFile do={
|
||||||
:global CleanFilePath;
|
:global CleanFilePath;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue