Handle script error mikrotik

I’m new in mikrotik Script and I have some question. Please help me resolve this:
1/ How can I get all wireless interface name in my device? Like wlan1, wlan2
2/ How can I get all SSID on my device?
3/ I have small script to remote config by using import command. That mean my device will get script from remote server and import this script on this device. I can’t handle the error when my device import script. How can I handle this because I want if script import successfull, my device will send some request to my server to told that this script running successfull. I have try using command
:do {
myscript
} on-error={
dosomething
}but that not work.
Thanks for your reply.

:foreach id  in [/interface wireless find] do={
 :put [/interface wireless get $id name]
}
:foreach id  in [/interface wireless find] do={
 :put [/interface wireless get $id ssid]
}
  1. Absence of normal error processing in ROS script is general problem %) (due to try/catch/return codes usually ignored)
    In your case I propose to put remote script importing into the separate script and when catch output of that scripts run by:
:execute script=importscript file=importres

In such case you will have file “importres” which can be analyzed for some special words like “error”,“success” etc
PS: but keep in mind you need wait some time after “:execute” to allow script finish. I use such trick for ftp ( Full backup script, function func_ftp, https://www.mikrotik-club.in.ua/list-of-scripts/ )

Thanks alots. You really saved my day.

I have 2 script
Script 1: importscript. That will be import from a config file

[/import file-name="wifi.rsc"]

Script 2: check the result of importscript

:execute script="importscript" file="importresult"
:delay 5s

I try add an error on the config file and you can see that script stop, I don’t get the result on importresult file.

How can I handle this error?

Try

:execute script="/import file-name=\"wifi.rsc\"" file="importresult"