Page 1 of 1

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

Posted: Sun Aug 27, 2017 2:30 pm
by asd8tw
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?

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

Posted: Sun Aug 27, 2017 10:50 pm
by asd8tw
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

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

Posted: Sun Aug 27, 2017 10:54 pm
by pe1chl
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).

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

Posted: Mon Aug 28, 2017 6:05 am
by asd8tw
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

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

Posted: Mon Aug 28, 2017 10:31 am
by pe1chl
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.

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

Posted: Mon Aug 28, 2017 11:17 am
by asd8tw
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.

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

Posted: Mon Aug 28, 2017 2:27 pm
by asd8tw
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).
==========================================================================

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

Posted: Mon Aug 28, 2017 2:51 pm
by pe1chl
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...

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

Posted: Tue Aug 29, 2017 3:59 am
by asd8tw
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...

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

Posted: Tue Aug 29, 2017 4:32 pm
by strods
You could use something like this to be sure that it will work:
while ([/ping domain_name count=1] != 1) do={:delay 0.2}

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

Posted: Fri May 27, 2022 7:35 pm
by bozallen
Appreciate this is a very old thread, but I was trying to achieve the same thing today - run a script containing /tool fetch from the PPP profile option on-up

I found the script needed to include permission policy=test to use /tool fetch. Then you can set dont-require-permissions=yes to allow the PPP profile to run the script.