script wireless registration table

Hello everyone!

I made this script to log the wireless registration table to a file, but when I’m performing a roaming to another ap it stops working. Can you suggest me a solution to this problem? Thanks!!


:if ([:len [/file find name="Signal1s.txt"]] != 1) do={
   /file print file=Signal1s
   :delay 2s;
   /file set Signal1s.txt contents="";
}


#definition of variables

:global rxpower 0;
:global radioname;
:global txpower 0;
:global signaltonoise 0;

:global count 0;
:global fileContent;


:for count from=1 to=30 step=1 do={
:set radioname [/interface wireless registration-table get [find where interface="wlan2"] radio-name];
 
:set fileContent [/file get Signal1s.txt content];

:set fileContent ($fileContent . $radioname);

/file set Signal1s.txt contents=($fileContent . "\t");

:set rxpower [/interface wireless registration-table get [find where interface="wlan2"] signal-strength];
 
:set fileContent [/file get Signal1s.txt content];

:set fileContent ($fileContent . $rxpower);

/file set Signal1s.txt contents=($fileContent . "\t");

:set txpower [/interface wireless registration-table get [find where interface="wlan2"] tx-signal-strength];
 
:set fileContent [/file get Signal1s.txt content];

:set fileContent ($fileContent . $txpower);

/file set Signal1s.txt contents=($fileContent . "\t");

:set signaltonoise [/interface wireless registration-table get [find where interface="wlan2"] signal-to-noise];
 
:set fileContent [/file get Signal1s.txt content];

:set fileContent ($fileContent . $signaltonoise);

/file set Signal1s.txt contents=($fileContent . "\r\n");
:delay 0.5s
}