Community discussions

 
mattyc94
just joined
Topic Author
Posts: 2
Joined: Tue May 15, 2018 7:55 pm

Find and Replace within an existing script

Tue May 15, 2018 8:02 pm

We have an existing script on our Routerboards containing an endpoint we would like to replace.

In the example below I would like to replace end.point.com with a new endpoint. Is this possible or is it best to remove the script entirely and add it in again with the new endpoint?

:local currentVPNServer [/interface ovpn-client get vpn-interface connect-to]
:local newVPNServer [/resolve end.point,com;
:if ([:len [:toip $newVPNServer]] > 0) do={
:if ( != ) do={
/interface ovpn-client set connect-to=$newVPNServer vpn-interface;
:log info "IP updated";
}
}

Thanks, Matt
 
2frogs
Long time Member
Long time Member
Posts: 540
Joined: Fri Dec 03, 2010 1:38 am

Re: Find and Replace within an existing script

Wed May 16, 2018 3:38 am

You can update the current script using:
/system script set [find  name=scriptname] source=":local currentVPNServer [/interface ovpn-client get vpn-interface connect-to];:local newVPNServer [/resolve newend.point,com;:if ([:len [:toip \$newVPNServer]] > 0) do={:if ( != ) do={/interface ovpn-client set connect-to=\$newVPNServer vpn-interface;:log info \"IP updated\";}}"
 
mattyc94
just joined
Topic Author
Posts: 2
Joined: Tue May 15, 2018 7:55 pm

Re: Find and Replace within an existing script

Wed May 16, 2018 11:13 am

Thanks for this. Will test it out.

Who is online

Users browsing this forum: No registered users and 19 guests