:execute END

Hi I would like to know if there is a posibility to know when :execute function finished.
If I don’t wait 1 second after execute the script dosn’t work because trys to add bridge on an interface not created by :execute yet…

:execute "/interface wireless security-profiles
		set [ find default=yes ] authentication-types=wpa-psk,wpa2-psk mode=\
			dynamic-keys wpa-pre-shared-key=$key wpa2-pre-shared-key=\
			$key
		add authentication-types=wpa-psk,wpa2-psk eap-methods=\"\" \
			management-protection=allowed name=free supplicant-identity=\"\"
		add authentication-types=wpa-psk,wpa2-psk eap-methods=\"\" \
			management-protection=allowed mode=dynamic-keys name=Private \
			supplicant-identity=\"\" wpa-pre-shared-key=$tPassw \
			wpa2-pre-shared-key=$tPassw";
	# espera final execute.
	:delay 1s		
	:execute "/interface wireless
		set [ find default-name=wlan1 ] band=2ghz-b/g/n  \
			disabled=no l2mtu=2290 mode=ap-bridge \
			security-profile=free ssid=\"Free\" wds-default-bridge=bridge-local \
			wds-mode=disabled wireless-protocol=802.11 country=spain
		add disabled=yes l2mtu=2290 master-interface=\
			wlan1 name=wlan1-Privada security-profile=Private ssid=\"Private\" \
			wds-cost-range=0 wds-default-cost=0";
	# espera final execute.
	:delay 1s
	/interface bridge port
	add bridge=bridge-local interface=wlan1-Privada
	add bridge=bridge-hs interface=wlan1

try using :do { } in stead of :execute.
(and you wouldn’t need to escape all of those quote marks)

If the reason you want to use :execute to begin with is because you have some variables, you can instead use a function variable, and pass parameters to it. Unlike :execute, calling the variable function should be done synchronously (i.e. the main script will wait for the function to finish).

I can see you’re using $tPassw and $key as variables, so:

:local modifySecurityProfile do={
    /interface wireless security-profiles
      set [ find default=yes ] authentication-types=wpa-psk,wpa2-psk mode=\
         dynamic-keys wpa-pre-shared-key=$key wpa2-pre-shared-key=\
         $key
      add authentication-types=wpa-psk,wpa2-psk eap-methods="" \
         management-protection=allowed name=free supplicant-identity=""
      add authentication-types=wpa-psk,wpa2-psk eap-methods="" \
         management-protection=allowed mode=dynamic-keys name=Private \
         supplicant-identity="" wpa-pre-shared-key=$tPassw \
         wpa2-pre-shared-key=$tPassw";
};

$modifySecurityProfile key=whatever tPassw=blabla;
/interface bridge port
  add bridge=bridge-local interface=wlan1-Privada
  add bridge=bridge-hs interface=wlan1

Hi boen_robot ,

the main reason to do :execute “” is because i want to execute this script even on a RB with wireless and RB without WIRELESS.
At the momento I have 2 scripts one for wireless RB and another for unwireless RB devices.
I like to have one script for both models, but if I add

 /interface wireless security-profiles
      set [ find default=yes ] authentication-types=wpa-psk,wpa2-psk mode=\
         dynamic-keys wpa-pre-shared-key=$key wpa2-pre-shared-key=\
         $key
      add authentication-types=wpa-psk,wpa2-psk eap-methods="" \
         management-protection=allowed name=free supplicant-identity=""
      add authentication-types=wpa-psk,wpa2-psk eap-methods="" \
         management-protection=allowed mode=dynamic-keys name=Private \
         supplicant-identity="" wpa-pre-shared-key=$tPassw \
         wpa2-pre-shared-key=$tPassw";

on an unwireless RB the script won’t work. So i need to encapsulate the sentence on an :execute.

Thanks

If that’s the reason, then as ZeroByte suggested, you can use “do {} on-error={}”. If the wireless menu can’t be reached, the script will fail right there and then, so f.e.

:do {
/interface wireless security-profiles
      set [ find default=yes ] authentication-types=wpa-psk,wpa2-psk mode=\
         dynamic-keys wpa-pre-shared-key=$key wpa2-pre-shared-key=\
         $key
      add authentication-types=wpa-psk,wpa2-psk eap-methods="" \
         management-protection=allowed name=free supplicant-identity=""
      add authentication-types=wpa-psk,wpa2-psk eap-methods="" \
         management-protection=allowed mode=dynamic-keys name=Private \
         supplicant-identity="" wpa-pre-shared-key=$tPassw \
         wpa2-pre-shared-key=$tPassw";
} on-error={
#Probably no wireless... Do wired here
}