Community discussions

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

Script running

Tue Apr 05, 2022 5:33 pm

Hello
Little help. Why I need tu run 2 times this script after every reboot, so massage is send over pushover. Only first time (after reboot) I need to run it twice so massage will be send. After first run nothing happen, after second I got report.
RBM11G ver 6.49.5


#Provera stanja kredita preko Ussd koda
/interface lte at-chat lte1 input="AT+CUSD=1,\"AAD82CA68A8D1A\",15" wait=yes

#Definisanje promenljive
:global ime;
:global message;
:set ime "$[/system identity get name]"

{
:local x
foreach i in=([/log find where message~"USSD: Kredit je"]) do={
:set $x [/log get $i message]
:set $message ($x)
}
:put $message
}
#Pushover
/tool fetch mode=https url="https://api.pushover.net/1/messages.json" http-method=post http-data="token=xxxxxxxxxxxxxxxxx&user=xxxxxxxxxxxxxx&sound=gamelan&priority=1&title=$ime&message=$message" keep-result=no

:log warning "Report send..."
:delay 15s
/system reboot
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 11982
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: Script running

Tue Apr 05, 2022 5:37 pm

first time after reboot?
set
:delay 60s
at start for give the time to go up all RouterBOARD components and also the LTE(?) modem.
 
nemke
Member Candidate
Member Candidate
Topic Author
Posts: 160
Joined: Thu Jul 31, 2014 2:52 am

Re: Script running

Tue Apr 05, 2022 10:14 pm

first time after reboot?
set
:delay 60s
at start for give the time to go up all RouterBOARD components and also the LTE(?) modem.
No no. After reboot of device, when I try to run script nothing happen. After I run it again it work. Again, also work. It is not importnat when I try it after reboot (one hour, two, or five) BUT first time don't work. I don't run it to soon so ROS is not up...like you write
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 11982
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: Script running  [SOLVED]

Tue Apr 05, 2022 10:41 pm

First of all, remove all errors, and also unknow language comments.
I do not understand Croatian and I do not know thet the string
"Provera stanja kredita preko Ussd koda" mean "Check the credit balance using the USSD code"
# Check the credit balance using the USSD code
/interface lte at-chat lte1 input="AT+CUSD=1,\"AAD82CA68A8D1A\",15" wait=yes

# Variables definition
:global ime [/system identity get name]
:global message ""

# Kredit je = Credit is
:foreach index in=[/log find where message~"USSD: Kredit je"] do={
    :set $message ([/log get $index]->"message")
}
:put $message

# pushover.net
/tool fetch mode=https url="https://api.pushover.net/1/messages.json" http-method=post keep-result=no \
    http-data="token=xxxxxxxxxxxxxxxxx&user=xxxxxxxxxxxxxx&sound=gamelan&priority=1&title=$ime&message=$message"
:log warning "Report send..."
:delay 15s
/system reboot
 
nemke
Member Candidate
Member Candidate
Topic Author
Posts: 160
Joined: Thu Jul 31, 2014 2:52 am

Re: Script running

Tue Apr 05, 2022 11:46 pm

First of all, remove all errors, and also unknow language comments.
I do not understand Croatian and I do not know thet the string
"Provera stanja kredita preko Ussd koda" mean "Check the credit balance using the USSD code"
# Check the credit balance using the USSD code
/interface lte at-chat lte1 input="AT+CUSD=1,\"AAD82CA68A8D1A\",15" wait=yes

# Variables definition
:global ime [/system identity get name]
:global message ""

# Kredit je = Credit is
:foreach index in=[/log find where message~"USSD: Kredit je"] do={
    :set $message ([/log get $index]->"message")
}
:put $message

# pushover.net
/tool fetch mode=https url="https://api.pushover.net/1/messages.json" http-method=post keep-result=no \
    http-data="token=xxxxxxxxxxxxxxxxx&user=xxxxxxxxxxxxxx&sound=gamelan&priority=1&title=$ime&message=$message"
:log warning "Report send..."
:delay 15s
/system reboot
Yes. your script work on first run. Try reboot 10 times and fter first run it work. Great. Thanks

Who is online

Users browsing this forum: eldoncito2019 and 23 guests