mirror of
https://git.eworm.de/cgit/routeros-scripts
synced 2025-06-26 11:38:36 +02:00
telegram-chat: ... and give a hint on failure
This commit is contained in:
parent
c2cf05e9e5
commit
a073835667
1 changed files with 4 additions and 1 deletions
|
@ -100,11 +100,14 @@ $WaitFullyConnected;
|
||||||
:local File ("tmpfs/telegram-chat/" . [ $GetRandom20CharAlNum 6 ]);
|
:local File ("tmpfs/telegram-chat/" . [ $GetRandom20CharAlNum 6 ]);
|
||||||
$MkDir "tmpfs/telegram-chat";
|
$MkDir "tmpfs/telegram-chat";
|
||||||
$LogPrintExit2 info $0 ("Running command: " . $Text) false;
|
$LogPrintExit2 info $0 ("Running command: " . $Text) false;
|
||||||
:exec script=(":do {\n" . $Text . "\n} on-error={};" . \
|
:exec script=(":do {\n" . $Text . "\n} on-error={ :execute script=\":put\" file=" . $File . ".failed };" . \
|
||||||
":execute script=\":put\" file=" . $File . ".done") file=$File;
|
":execute script=\":put\" file=" . $File . ".done") file=$File;
|
||||||
:if ([ $WaitForFile ($File . ".done.txt") 200 ] = false) do={
|
:if ([ $WaitForFile ($File . ".done.txt") 200 ] = false) do={
|
||||||
:set State "The command did not finish, still running in background.\n\n";
|
:set State "The command did not finish, still running in background.\n\n";
|
||||||
}
|
}
|
||||||
|
:if ([ :len [ /file/find where name=($File . ".failed.txt") ] ] > 0) do={
|
||||||
|
:set State "The command failed with an error!\n\n";
|
||||||
|
}
|
||||||
:local Content [ /file/get ($File . ".txt") content ];
|
:local Content [ /file/get ($File . ".txt") content ];
|
||||||
$SendTelegram2 ({ origin=$0; silent=false; \
|
$SendTelegram2 ({ origin=$0; silent=false; \
|
||||||
subject=([ $SymbolForNotification "speech-balloon" ] . "Telegram Chat"); \
|
subject=([ $SymbolForNotification "speech-balloon" ] . "Telegram Chat"); \
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue