Script for control registration

Hi,
on many AP I have a problem with registration of mikrotik clients - there are 2 states:

  1. state: on AP is not connected any device - after disable/enable wlan interface is everything correct
  2. state: on AP are registred clients but doesn’t response on ping, mactelnet and others - after disable/enable wlan interface is everything correct too
    Could you help me with script - which could ping first 2 registred clients (defined in variables) and restart wlan card?
    Thanks for your help with this problem