<div dir="ltr">Here is a simple example on how to read device MAC address in Linux<br><br>{$mode objfpc}<br>program get_mac;<br>uses sysutils;<br><br>const<br> linux_path = '/sys/class/net/%s/address';<br> default_device = 'eth0';<br>
<br>var<br> f : textfile;<br> device,<br> path,<br> addr : string;<br><br>begin<br> device := default_device;<br><br> if (ParamCount = 1) then<br> begin<br> device := ParamStr(1);<br> end;<br>
<br>
path := Format(linux_path,[device]);<br> if Not FileExists(path) then<br> begin<br> writeln('Could not find the device: ', device);<br> halt(1);<br> end;<br><br> AssignFile(f, path);<br>
reset(f);<br>
readln(f,addr);<br> closefile(f);<br><br> writeln(device, ' MAC Address: ', addr);<br>end.<br><br>Ido<br clear="all"><a href="http://ik.homelinux.org/">http://ik.homelinux.org/</a><br>
<br><br><div class="gmail_quote">2010/5/10 Leonardo M. <span dir="ltr"><<a href="mailto:l.rame@griensu.com">l.rame@griensu.com</a>></span><br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
Hi, does anyone knows how to get the MAC address of a NIC using<br>
Lazarus/FPC on Linux?.<br>
<br>
P.S.: I found plenty of examples using Delphi's "Nb30" unit, only for<br>
Windows.<br>
<br>
--<br>
Leonardo M. Ramé<br>
Griensu S.A. - Medical IT Córdoba<br>
Tel.: 0351-4247979<br>
<font color="#888888"><br>
<br>
--<br>
_______________________________________________<br>
Lazarus mailing list<br>
<a href="mailto:Lazarus@lists.lazarus.freepascal.org">Lazarus@lists.lazarus.freepascal.org</a><br>
<a href="http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus" target="_blank">http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus</a><br>
</font></blockquote></div><br></div>