Hi all,
Consider the following example script:
:if ([/system package find name=wireless disabled=no] = "") do={
:log info "Wireless package is not installed.";
} else={
/interface wireless security-profiles add \
authentication-types=wpa-psk,wpa2-psk,wpa-eap,wpa2-eap \
eap-methods=passthrough group-ciphers=tkip,aes-ccm group-key-update=5m \
interim-update=0s mode=dynamic-keys name=DELETEME \
unicast-ciphers=tkip,aes-ccm \
wpa-pre-shared-key="XXXXXXXXXX" wpa2-pre-shared-key="XXXXXXXXXX";
/interface wireless security-profiles remove [find name="DELETEME"];
}
It checks that the wireless package is installed and enabled and, if not, it should log an info message. If the package is installed and enabled, it creates a security profile and then deletes it again.
When the script is run, if the wireless package is installed and enabled, it works perfectly - the profile is added and then deleted correctly.
If the wireless package is not installed or is disabled, the script will not run:
Opening script file wifitest.rsc
Script file loaded successfullyexpected end of command (line 10 column 63)
It looks to me like the script is being parsed before it is being executed and is failing because the ‘/interface wireless’ commands are not valid.
Given that I explicitly check that the package is installed and enabled and DO NOT run that code if it is not, it is rather annoying to have the script fail.
The only way around this I can see is to do something like:
:if ([/system package find name=wireless disabled=no] = "") do={
:log info "Wireless package is not installed.";
} else={
/system script add name=TEMPWIFI policy=ftp,reboot,read,write,policy,test,winbox,sniff source="\r\
\n/interface wireless security-profiles add \\\r\
\nauthentication-types=wpa-psk,wpa2-psk,wpa-eap,wpa2-eap \\\r\
\neap-methods=passthrough group-ciphers=tkip,aes-ccm group-key-update=5m \
\\\r\
\ninterim-update=0s mode=dynamic-keys name=DELETEME \\\r\
\nunicast-ciphers=tkip,aes-ccm \\\r\
\nwpa-pre-shared-key=\"XXXXXXXXXX\" wpa2-pre-shared-key=\"XXXXXXXXXX\";\r\
\n/interface wireless security-profiles remove [find name=\"DELETEME\"];\r\
\n"
/system script run TEMPWIFI;
/system script remove TEMPWIFI;
}
Which is a horrible botch way of doing things…
Any ideas anybody?