Community discussions

MikroTik App

Search found 14 matches

by pkt
Tue Mar 21, 2023 12:48 am
Forum: Scripting
Topic: Black list for failed login to IPSec VPN
Replies: 68
Views: 42670

Re: Black list for failed login to IPSec VPN

Do not use ({}) for define empty array, the correct way is :local arrayvar [:toarray ""] I myself used that method once suggested by another user, but it backfired because, although I don't quite remember now how, it had unwanted effects that backfired on me in programming. IT SEEMS to wo...
by pkt
Wed Feb 08, 2023 11:08 pm
Forum: Scripting
Topic: Send SMS messages via Huawei LTE modem API (tested with E3372)
Replies: 84
Views: 26341

Re: Send SMS messages via Huawei LTE modem API (tested with E3372)

How can I do to execute an action if <Count> is >0. I think this will work even if Count tag is empty or non-existent: :global tokenParser :global recvSMS :local xmlSmsList ([$recvSMS]->"data") :local smsCount [:tonum [($tokenParser->"getTag") source=$xmlSmsList tag="Count&...
by pkt
Wed Feb 08, 2023 10:50 pm
Forum: Scripting
Topic: Send SMS messages via Huawei LTE modem API (tested with E3372)
Replies: 84
Views: 26341

Re: Send SMS messages via Huawei LTE modem API (tested with E3372)

I wonder if it is possible to work with SMS with a "secure" API - there should be the possibility of authorization to access the API ... AFAIK, user-password authentication in HiLink returns access tokens in the headers of the http response and /tool/fetch has no way to get them, so it's ...
by pkt
Tue Feb 07, 2023 12:16 am
Forum: Scripting
Topic: Send SMS messages via Huawei LTE modem API (tested with E3372)
Replies: 84
Views: 26341

Re: Send SMS messages via Huawei LTE modem API (tested with E3372)

Maybe you have not delSMS in scope.

If it is not defined in the same script or function in which is used, it's necessary to "import" the symbol declaring it.

You can try to put :global delSMS in a line before the foreach one.
by pkt
Mon Feb 06, 2023 10:04 pm
Forum: Scripting
Topic: Send SMS messages via Huawei LTE modem API (tested with E3372)
Replies: 84
Views: 26341

Re: Send SMS messages via Huawei LTE modem API (tested with E3372)

Hello, Rex! No, these modems of mine don't send SMS via API... They are sent from the WEB interface without any problems... You can try this in terminal to test if you can authenticate with HiLink API (assuming modem IP is 192.168.8.1 ): [admin@MikroTik] > :put [/tool fetch "http://192.168.8.1...
by pkt
Mon Feb 06, 2023 9:44 pm
Forum: Scripting
Topic: Send SMS messages via Huawei LTE modem API (tested with E3372)
Replies: 84
Views: 26341

Re: Send SMS messages via Huawei LTE modem API (tested with E3372)

SMS messages are not deleted delSMS had a few errors. New version: :global delSMS do={ :local lteIP "192.168.8.1" :global tokenParser # get SessionID and Token via LTE modem API :local urlSesTokInfo "http://$lteIP/api/webserver/SesTokInfo" :local api [/tool fetch $urlSesTokInfo ...
by pkt
Mon Feb 06, 2023 12:48 am
Forum: Scripting
Topic: Send SMS messages via Huawei LTE modem API (tested with E3372)
Replies: 84
Views: 26341

Re: Send SMS messages via Huawei LTE modem API (tested with E3372)

I thought that you wanted to send one email for each sms. In that case the script would be something like this: ... :foreach tagContent in=$smsList do={ # tagContent - content of tag :local index [($tokenParser->"getTag") source=$tagContent tag="Index"] :local phone [($tokenParse...
by pkt
Sun Feb 05, 2023 11:03 am
Forum: Scripting
Topic: Can somebody explain how this script works?
Replies: 5
Views: 2608

Re: Can somebody explain how this script works?

I have also run into this nasty bug of [...] executing all functions in the script. In my case, the function first called was not the first declared, but the first in alphabetical order: deleteSMS. I guess this was because all functions were "methods" of an array, and as array members are ...
by pkt
Sun Feb 05, 2023 10:55 am
Forum: Scripting
Topic: Send SMS messages via Huawei LTE modem API (tested with E3372)
Replies: 84
Views: 26341

Re: Send SMS messages via Huawei LTE modem API (tested with E3372)

Using local storage is great idea. This way there are no risk of exceeding the (not documented) storage capacity of the modem.

Thanks for the code, I will make good use of it. I have already reused successfully some of your snippets in my hilink routines..
by pkt
Sat Feb 04, 2023 11:29 am
Forum: Scripting
Topic: Send SMS messages via Huawei LTE modem API (tested with E3372)
Replies: 84
Views: 26341

Re: Send SMS messages via Huawei LTE modem API (tested with E3372)

Afaik, you can't delete the entire inbox with one command. But can do it one message at a time using its index. In the delete request, instead of <Index>10</Index> use <Index>$index</Index> . And then (not tested): ... :local index ([($tokenParser->"getTag") source=$tagContent tag="In...
by pkt
Fri Feb 03, 2023 1:23 am
Forum: Scripting
Topic: Send SMS messages via Huawei LTE modem API (tested with E3372)
Replies: 84
Views: 26341

Re: Send SMS messages via Huawei LTE modem API (tested with E3372)

I have tested (read back) to receive SMS and process the content, without success. The recvSMS works well, but retrieves a bunch of sms messages at a time. The getBetween parser is very limited and can only process the first appearance ot each tag. I've a more advanced parser that walks incremental...
by pkt
Fri Feb 03, 2023 12:57 am
Forum: Scripting
Topic: Send SMS messages via Huawei LTE modem API (tested with E3372)
Replies: 84
Views: 26341

Re: Send SMS messages via Huawei LTE modem API (tested with E3372)

...the author to tell me exactly... These scripts are contributed unselfishly by its creators. It's unfair to expect or demand them any kind of guarantee about its applicability. For this kind of info you should contact the modem manufacturer or vendor. I think that there are two kind of HiLink dev...
by pkt
Mon Jan 30, 2023 9:24 pm
Forum: Scripting
Topic: How to get command output inside a script without printing it to the terminal?
Replies: 16
Views: 3577

Re: How to get command output inside a script without printing it to the terminal?

:set $prefix [/routing/route/print count-only where belongs-to="bgp-IP-$remote"] not only puts the value in $prefix but also outputs it to the terminal. How can I suppress that? I think this is done with as-value . Code will be: :set prefix [/routing/route/print as-value count-only where ...
by pkt
Wed Jan 25, 2023 8:55 pm
Forum: Scripting
Topic: Function of transferring the script over SSH
Replies: 20
Views: 4123

Re: Function of transferring the script over SSH

Elaborating that script, is possible to send file with size less than 63K by SSH...
This will be very interesting, but it seems that it is needed to load the file in memory to pass it to ssh-exec.
How do you will overcome the 4K limit?