Community discussions

MikroTik App
 
asd8tw
just joined
Topic Author
Posts: 12
Joined: Fri Nov 14, 2014 8:20 pm

scripts in profile [On UP/Down] can't run "/tool fetch"

Sun Aug 27, 2017 2:30 pm

I want to update ddns when my PPPoE on UP.
So I wrote some scripts in the profile (on UP) of the PPPoE.

But the script stopped when running "/tool fetch".
Is there a bug on that command?
 
asd8tw
just joined
Topic Author
Posts: 12
Joined: Fri Nov 14, 2014 8:20 pm

Re: scripts in profile [On UP/Down] can't run "/tool fetch"

Sun Aug 27, 2017 10:50 pm

I just tested.
When I run script by [On UP] in PPPoE profiles.
The Owner would be "*sys" instead of "admin".

Is this the reason that "/tool fetch" cant not work?

Thanks
 
pe1chl
Forum Guru
Forum Guru
Posts: 6494
Joined: Mon Jun 08, 2015 12:09 pm

Re: scripts in profile [On UP/Down] can't run "/tool fetch"

Sun Aug 27, 2017 10:54 pm

Maybe you should try to set a flag (global variable) in the on-up script and put your originally intended actions in a scheduled
script that checks the flag. You can schedule it to run as often as you deem necessary (like once per minute).
 
asd8tw
just joined
Topic Author
Posts: 12
Joined: Fri Nov 14, 2014 8:20 pm

Re: scripts in profile [On UP/Down] can't run "/tool fetch"

Mon Aug 28, 2017 6:05 am

I want to update the ddns immediately. once my PPPoE IP changed.

Now my alternative method is writing the following script in the on-up script

Code: Select all

/system scheduler set [find name=pppoe_run] interval=1s
and

run the following script after the ddns was updated.

Code: Select all

/system scheduler set [find name=pppoe_run] interval=10m
It can work well and update ddns immediately now.

But I really want to use "/tool fetch" in the on-up script, so that I dont need to write too many extra scripts to prevent DDNS updates too many times during interval=1s scheduler.

Thanks
 
pe1chl
Forum Guru
Forum Guru
Posts: 6494
Joined: Mon Jun 08, 2015 12:09 pm

Re: scripts in profile [On UP/Down] can't run "/tool fetch"

Mon Aug 28, 2017 10:31 am

I guess that is not possible because the on-up script is called at a time the connection is transitioning from down to up and not all actions have been completed.
(e.g. the adding of the default route obtained from PPP has not yet completed)

Having a DDNS entry within a second after PPPoE coming up should be fine.
 
asd8tw
just joined
Topic Author
Posts: 12
Joined: Fri Nov 14, 2014 8:20 pm

Re: scripts in profile [On UP/Down] can't run "/tool fetch"

Mon Aug 28, 2017 11:17 am

Thanks for discussing this topic

I tested a 60s delay command like the following picture.
It run well, and show "PPPoE UP start" and "PPPoE UP done" perfectly.

So I guess it is not a transition issue.

Image
I guess that is not possible because the on-up script is called at a time the connection is transitioning from down to up and not all actions have been completed.
(e.g. the adding of the default route obtained from PPP has not yet completed)

Having a DDNS entry within a second after PPPoE coming up should be fine.
 
asd8tw
just joined
Topic Author
Posts: 12
Joined: Fri Nov 14, 2014 8:20 pm

Re: scripts in profile [On UP/Down] can't run "/tool fetch"

Mon Aug 28, 2017 2:27 pm

The support replied me as follow information.
And It works.
My problem solved.
Thanks
==========================================================================
Hello,
We've put your script to our PPPoE server and it worked properly.
1) Add delay at the beginning, :delay 5s
2) Please make sure you are using 6.40.x version, make sure your router can resolve mikrotik.com (ping mikrotik.com).
==========================================================================
 
pe1chl
Forum Guru
Forum Guru
Posts: 6494
Joined: Mon Jun 08, 2015 12:09 pm

Re: scripts in profile [On UP/Down] can't run "/tool fetch"

Mon Aug 28, 2017 2:51 pm

So you are happy with their solution that causes 5 second delay but not with my solution that causes 1 second delay because you want "immediate"?
Strange...
 
asd8tw
just joined
Topic Author
Posts: 12
Joined: Fri Nov 14, 2014 8:20 pm

Re: scripts in profile [On UP/Down] can't run "/tool fetch"  [SOLVED]

Tue Aug 29, 2017 3:59 am

Actually I just add 1 second delay, it works.
I guess the 1 second is waiting the DNS servic ready to resolve the Domain Name.

If I write a [interval=1s scheduler] , It takes more resources.
I have to write more [if/do/else] command to check whether the IP changed.
and more [if/do/else] command to prevent the same script running at that short time.

On-Up Scripts just run once, and I don't need to check the IP changed or not.
The only procedure is to update the DDNS.
It is simple and use less resource.

Thanks
So you are happy with their solution that causes 5 second delay but not with my solution that causes 1 second delay because you want "immediate"?
Strange...
 
User avatar
strods
MikroTik Support
MikroTik Support
Posts: 1431
Joined: Wed Jul 16, 2014 7:22 am
Location: Riga, Latvia

Re: scripts in profile [On UP/Down] can't run "/tool fetch"

Tue Aug 29, 2017 4:32 pm

You could use something like this to be sure that it will work:
while ([/ping domain_name count=1] != 1) do={:delay 0.2}

Who is online

Users browsing this forum: ErfanDL, Google [Bot] and 29 guests