mirror of
https://git.eworm.de/cgit/routeros-scripts
synced 2025-07-31 16:24:25 +02:00
global-functions: introduce $RmFile
This commit is contained in:
parent
4bfb591fa0
commit
4542c2b19e
1 changed files with 21 additions and 0 deletions
|
@ -63,6 +63,7 @@
|
||||||
:global ProtocolStrip;
|
:global ProtocolStrip;
|
||||||
:global RandomDelay;
|
:global RandomDelay;
|
||||||
:global RequiredRouterOS;
|
:global RequiredRouterOS;
|
||||||
|
:global RmFile;
|
||||||
:global ScriptFromTerminal;
|
:global ScriptFromTerminal;
|
||||||
:global ScriptInstallUpdate;
|
:global ScriptInstallUpdate;
|
||||||
:global ScriptLock;
|
:global ScriptLock;
|
||||||
|
@ -1004,6 +1005,26 @@
|
||||||
:return true;
|
:return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# remove file
|
||||||
|
:set RmFile do={
|
||||||
|
:local FileName [ :tostr $1 ];
|
||||||
|
|
||||||
|
:global LogPrint;
|
||||||
|
|
||||||
|
:local File [ /file/find where name=$FileName type=file ];
|
||||||
|
:if ([ :len $File ] = 0) do={
|
||||||
|
:return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
:do {
|
||||||
|
/file/remove $File;
|
||||||
|
} on-error={
|
||||||
|
$LogPrint error $0 ("Removing file '" . $FileName . "' (" . $File . ") failed.");
|
||||||
|
:return false;
|
||||||
|
}
|
||||||
|
:return true;
|
||||||
|
}
|
||||||
|
|
||||||
# check if script is run from terminal
|
# check if script is run from terminal
|
||||||
:set ScriptFromTerminal do={
|
:set ScriptFromTerminal do={
|
||||||
:local Script [ :tostr $1 ];
|
:local Script [ :tostr $1 ];
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue