Search code examples
c#apinetwork-programmingmikrotik

MikroTik and c# API: get radio-name with ':put' command


I have an issue. I want to get radio-name through the C# api for winbox. In winboxs terminal works :put [/interface wireless get [/interface wireless find default-name=wlan1] radio-name] command, but not in C# api. I rode that, in api i can't uses [ ] marks, but i dont know how it write without it. I tried like this:

mikrotik.Send("/put ", true);
mikrotik.Send(".system identity get name", true);
foreach (string h in mikrotik.Read())
    {
         mkResult += h;
    }

l_identify.Text = mkResult;

but its doesn't work. Everytime i get this:

!trap=category=0=message=no such command or directiory (put [)!trap=message=no such command prefix!done

Please help :<

PS: Sorry for my English :P


Solution

  • You are sending incorrect commands to the device.

    You need to use this:

    /interface/wireless/print
    =.proplist=radio-name
    ?default-name=wlan1
    

    .proplist contains list of fields to be returned, ?default-name=wlan1 is a condifion for filtering.

    You can find more about Mikrotik API syntax in the official Wiki.