routeros-scripts/sms-action
Christian Hesse ceaa83b83e global-functions: merge $LogAnd{Error,Put} to $LogPrintExit ...
... and fix logging.

Logging with severity from variable (:log $severity ...) is not
possible, this is considered a syntax error. Also the 'workaround' with
parsing code failed with missing message in log.

The reliable code is a lot longer, so merge the two functions to save a
lot of duplicate code.
2020-02-26 14:19:54 +01:00

22 lines
482 B
Text

#!rsc
# RouterOS script: sms-action
# Copyright (c) 2018-2020 Christian Hesse <mail@eworm.de>
#
# run action on received SMS
:global SmsAction;
:global LogPrintExit;
:local Action $action;
:if ([ :typeof $Action ] = "nothing") do={
$LogPrintExit error "This script is supposed to run from SMS hook with action=..." true;
}
:local Code ($SmsAction->$Action);
:local Parsed [ :parse $Code ];
:log info ("Acting on SMS action '" . $Action . "': " . $Code);
:delay 1s;
$Parsed;