Community discussions

MikroTik App
 
David1234
Forum Guru
Forum Guru
Topic Author
Posts: 1424
Joined: Sun Sep 18, 2011 7:00 pm

about autoscript log

Wed Dec 09, 2020 1:43 pm

Hello
I have uplaod a script tp the router called
script.auto.rsc
start to work auto - as it should
but he got stuck on the way (my mistake )
I can see in the log where is the problem

why it doesn't say also in the
script.auto.log
what was the error ?

Thanks ,
 
User avatar
SiB
Forum Guru
Forum Guru
Posts: 1888
Joined: Sun Jan 06, 2013 11:19 pm
Location: Poland

Re: about autoscript log

Thu Dec 10, 2020 11:00 am

this works only if you send it via FTP
 
David1234
Forum Guru
Forum Guru
Topic Author
Posts: 1424
Joined: Sun Sep 18, 2011 7:00 pm

Re: about autoscript log

Thu Dec 10, 2020 12:31 pm

I have uplaod it using FTP
and when the script is working (wihtout any mistakes)- I get "script upload success"
I want to get the errors to be wriiting also to the files if there is a problem
 
User avatar
SiB
Forum Guru
Forum Guru
Posts: 1888
Joined: Sun Jan 06, 2013 11:19 pm
Location: Poland

Re: about autoscript log

Thu Dec 10, 2020 2:18 pm

I have uplaod it using FTP
Very good. User should have all permision, like Full group. You can next experiment and create own group without necessery permition but remember after some upgrade RouterOS some rights can be change.
.
.
and when the script is working (wihtout any mistakes)- I get "script upload success"
I always put at end of script line to remove itself and this is confirmation for me the error not exist and last self destruction was done. This remove old .log who have old errors as regex script.auto* .
.
/delay delay-time=2s;
/file remove [find name~"script.auto"];
/put "TheEnd";
.
.
I want to get the errors to be wriiting also to the files if there is a problem
I just use /put in script body in some lines like chapters, this is printed in script.auto.log file and I can assume at what part error happens. You can put blocks of code into :do={} on-error={put "error1"} to have errors only if he exist.
.
put "Starting..."
put "Doint clean up..."
put "Starting action..."
put "The End..."
.
for example file mp_ntp.auto.rsc have body:
.
/put "Starting..."
/system clock set time-zone-name=Europe/Warsaw
/system ntp client set enabled=yes primary-ntp=[:resolve tempus1.gum.gov.pl] secondary-ntp=[:resolve tempus2.gum.gov.pl]
/put "Done";

/delay delay-time=2s;
/file remove [find name~"mp_ntp.auto"];
/put "TheEnd";
 
David1234
Forum Guru
Forum Guru
Topic Author
Posts: 1424
Joined: Sun Sep 18, 2011 7:00 pm

Re: about autoscript log

Sun Dec 13, 2020 3:33 pm

this is what I did
but if you have problem in the script
let say typo mistake or you try to change interface that isn't there
(for example you try to change ppp-out interface phone nmber , and there is not ppp-out interfance ....)
you will now know this , the script will get stuck
I want to be able to get the error that is printing in the log
 
User avatar
SiB
Forum Guru
Forum Guru
Posts: 1888
Joined: Sun Jan 06, 2013 11:19 pm
Location: Poland

Re: about autoscript log

Sun Dec 13, 2020 8:25 pm

thats why we must use a FIND operator.
We can use :do on-error={}
We can use print do debug problems.

But, when I create a new script then always I run it few times to check if it not create few times the same stuff.
Two differ scripts per few differ platform like wifi for old wlan1 only and second one who use wlan1 and wlan2.
 
David1234
Forum Guru
Forum Guru
Topic Author
Posts: 1424
Joined: Sun Sep 18, 2011 7:00 pm

Re: about autoscript log

Sun Jan 03, 2021 10:15 am

I also chekc before I creae a new script
but as you know - sometimes you get errors you didn't think about
 
User avatar
SiB
Forum Guru
Forum Guru
Posts: 1888
Joined: Sun Jan 06, 2013 11:19 pm
Location: Poland

Re: about autoscript log

Tue Feb 23, 2021 2:08 am

but as you know - sometimes you get errors you didn't think about
That's why at the end we can use a double-check monitor action what dev use for cron monitoring... if no request at the end of script then do alarm... some online project are like "Dead Man’s Snitch" but when you type "cron monitor" then you can get many of that services.

Who is online

Users browsing this forum: Ahrefs [Bot], mhenriques and 22 guests