Community discussions

MikroTik App
 
nemke
Member Candidate
Member Candidate
Topic Author
Posts: 119
Joined: Thu Jul 31, 2014 2:52 am

Send specific log line over sms

Thu Nov 19, 2020 1:01 am

I am terible in scripting

I need script to send specific log over SMS

Example
Every 15 days, MT check SIM credit bilans over Ussd codes. So now I like to send that reply over SMS to my number.
After MT sheck SIM credit, in Log i see line "USSD: Your credic is 17Eur"
So now I like just to copy this and send over SMS to my number

Help ?
 
nemke
Member Candidate
Member Candidate
Topic Author
Posts: 119
Joined: Thu Jul 31, 2014 2:52 am

Re: Send specific log line over sms

Fri Nov 20, 2020 10:13 pm

To be exact I need just BOLD part, how to copy specific massage from log, and make $output to use it like message for Pushpver and SMS

#SCRIPT shows USSD SIM balans and send over SMS &/or Pushover
#SIM Balans check
/interface lte at-chat lte1 input="AT+CUSD=1,\"AAD82CA68A8D1A\",15" wait=yes

#Wait 10 sec
:delay 10s

#Define $output. Find Log with word "USSD" Copy all log line message
:global ime;
:set ime "$[/system identity get name]";

:local startBuf [:toarray [ /log find where message ~"USSD"]];
:local output "$[/log get [:pick $currentBuf] message ]";


#Send over Pushover
/tool fetch mode=https url="https://api.pushover.net/1/messages.json" http-method=post http-data="token=xxxxxxxxxxxxxxx&user=xxxxxxxxxxxxxxxx&sound=gamelan&priority=0&title=$ime&message=$output" keep-result=no

#Send ove SMS
/tool fetch send sms port=lte1 phone-number=xxxxxxx message=$output

:log info "Report Send"
 
nemke
Member Candidate
Member Candidate
Topic Author
Posts: 119
Joined: Thu Jul 31, 2014 2:52 am

Re: Send specific log line over sms

Mon Nov 23, 2020 10:41 pm

Anyone have something simular ?

Who is online

Users browsing this forum: No registered users and 27 guests