It works in terminal but not in script or in scheduler.HELP!

It will be used to do port-map.
It works in terminal but not in script or in scheduler.is there somebody can help me ?

:global newipaddress 
:global oldipaddress
:set newipaddress [/ip address get [/ip address find  interface="pppoe-out1"] address] 
:set newipaddress [:pick $newipaddress 0 ([:len $newipaddress] -3)] 
:set oldipaddress [/ip firewall nat get [/ip firewall nat find comment=23] dst-address] 

:put $newipaddress
:put $oldipaddress

:if ($newipaddress != $oldipaddress) do={/ip firewall nat set [/ip firewall nat find comment=23] dst-address=$newipaddress}

If all you’re trying to do is change IPs on a port forward rule in NAT, there is no need for that. Just replace “dst-address=a.b.c.d” with “in-interface=pppoe1-out”.

with “in-interface=pppoe1-out”,there are some problem when visit internal server by external ip from client behind routeros.
so i do port-map whit dst-address.

The “:put” command works only in console, not with the scheduler. Change “:put” to “:log info” and try it again.

I add “:put” to find problem point。
It doesn’t work even i delete “:put” lines.

:frowning: :frowning: :frowning:

It works here. What output do you get when you run the script from the console? I got errors if the interface name or the comment did not exist.