elico
January 18, 2021, 12:44pm
1
I have a nice setup with pppoe/l2tp/pptp server it works great of course.
I wanted to trigger a remote api call using “/tool fetch” however it doesn’t work.
I am trying to run the next:
/tool fetch address=192.168.200.80 host=192.168.200.80 mode=http src-path=login output=none;
:log info "#####$user LOGIN";
But for some reason both the tool fetch and the log are not working one after the other.
The log by itself works and then I am adding the fetch and it stops works.
Is there any way to run the fetch tool in “On Up” script?
What are my options to run a fetch tool?
mrz
January 19, 2021, 8:56am
2
ppp on-up script has limited permissions.
You need to add a script with “dont-require-permissions” set to yes and execute it from ppp on-up.
elico
January 19, 2021, 5:10pm
3
My main concern is the user variable.
I need it for the fetch script.
What are my options?
mrz
January 20, 2021, 8:13am
4
If a script is executed from PPP on-up, then the user variable will be available.
elico
January 20, 2021, 2:26pm
5
@mrz , I am trying to figure out how to do that but can’t.
I have the next in the ppp on-up script:
:log info "****** $user Connected";
/system script run test;
and in the test script:
:log info "#####$user Connected";
The logs shows:
****** eliezer Connected
Connected
So it’s not accessible directly.
There are other issues.
Let say I have used a variable, a global variable is too wide.
Would a local variable work?
mrz
January 21, 2021, 8:17am
6
Add a script in system scripts menu
/system script add name=myScript source={ :log info “****** $user Connected”; }
Then set:
on-up=myScript
elico
January 24, 2021, 5:56am
7
Thanks, Eventually I managed to make it work with the next is my script:
:do {
:local Url ("http://ngtech.co.il/index.html");
/tool fetch url=$Url keep-result=no;
:log info "*****$user Connected";
} on-error={
:log info "Error";
}
:log info "#####$user Connected";
The on-error is called on a 404 so it’s a bit weird for me.
By the way a selection can be added to the winbox menu to select a script or write one.