how to know if ethernet is disabled

hello

anybody can help me with this script ?

how can i determine if ether1 is disabled ? if yes i want to disable ether5

/interface get ether1 disabled] = yes do={ /interface disable ether5}

how to correct this scirpt ?

regards

hi
copy the script to system sheduler and set a certain time interval :/1m

:do {
:local int1 ether1
:local int5 ether5
:foreach a in=[/interface find name=$int1] do={
:local status [/interface get $a disabled];
:if ($status=true) do={
/interface disable [/interface find name=$int5];};
:if ($status!=true) do={
/interface enable [/interface find name=$int5];};
};};

Happy learning

thank you for your reply

actually the script works fine for me but i want to make some edit on it

what i want to make is if i unplugged the cable from ether1 then the ether5 should be disabled and when i plug the cable to ehter1 then ehter5 will enable

thank you very much

This script does what you’re looking for. It detects whether ether1 has something plugged in or not, and disables / enables ether5 accordingly. I also added functionality to check ether5’s status before doing anything. That way, if ether5 is already disabled, it won’t re-disable it, or on the flip side if it’s already enabled, it won’t re-enable it, performing unnecessary actions.

:do {
	:local int1 ether1;
	:local int5 ether5;
	:foreach a in=[/interface find name=$int1] do={
		:local status [/interface get $a running];
		:local e5status [/interface get $int5 disabled];
		:if ($status=true && $e5status=true) do={
			/interface enable [/interface find name=$int5];
		}
		:if ($status=false && $e5status=false) do={
			/interface disable [/interface find name=$int5];
		}
	}
}