Community discussions

MikroTik App
 
oliverbedi
just joined
Topic Author
Posts: 22
Joined: Thu Aug 10, 2017 11:49 am

mac address export script to file

Sun Aug 05, 2018 10:32 pm

Halo,

I want to create script which do export all mac address from leases list to file like:

create file.txt and intro file is:
11-22-33-44-55-66
aa-bb-cc-dd-ee-ff-gg




and after create this file mikrotik connect to my UniFi AP via SSH and import mac address to white list security connection.

Know this procedure alone mikrotik? Or any better idea?
 
sutrus
Frequent Visitor
Frequent Visitor
Posts: 58
Joined: Fri Jun 30, 2017 11:27 pm

Re: mac address export script to file

Mon Aug 06, 2018 12:12 am

:local output ""
:local filename "mac_address.txt";

:foreach i in=[/ip dhcp-server lease find] do={	
   :set output ($output . [/ip dhcp-server lease get $i mac-address] . "\n");
}
/file print file=$filename;
:delay 1;
/file set [/file find name=$filename] contents=$output;
 
oliverbedi
just joined
Topic Author
Posts: 22
Joined: Thu Aug 10, 2017 11:49 am

Re: mac address export script to file

Mon Aug 06, 2018 9:37 pm

Wow, is perfect!

Thanx

What is a language? And where I find material for learning??
 
User avatar
nichky
Forum Guru
Forum Guru
Posts: 1278
Joined: Tue Jun 23, 2015 2:35 pm

Re: mac address export script to file

Mon Aug 06, 2018 10:42 pm

Can you update your script. So it works pretty well but, what i found is when im opening the file it goes like 0C:EA:99:97:XX:XX0C:EA:99:79:XX:XX Can you change to get information like:

0C:EA:99:97:XX:XX
0C:EA:99:79:XX:XX

Who is online

Users browsing this forum: No registered users and 23 guests