lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


steve donovan <steve.j.donovan@gmail.com> writes:
>> One thing to be aware is that the above strings change according to OS
>> language; also there could be other (possibly virtual) network cards, so
>> extracting the desired MAC address from the output of 'ipconfig /all' isn't
>> always straightforward.
>
> Yes, I forgot that Windows speaks other languages ;)

ifconfig can be localized too...!

   $ /sbin/ifconfig
   eth0      Link encap:イーサネット  ハードウェアアドレス 00:1f:d0:55:4c:52 
             inetアドレス:192.168.0.2 ブロードキャスト:192.168.0.255  マスク:255.255.255.0
   ...

in most cases though, an easy solution when you want to parse the output
is to just set LANG=C in the environment passed to the subprocess, e.g.:

   Lua 5.1.4  Copyright (C) 1994-2008 Lua.org, PUC-Rio
   > print (io.popen ("/sbin/ifconfig"):lines ()())
   eth0      Link encap:イーサネット  ハードウェアアドレス 00:1f:d0:55:4c:52 
   > print (io.popen ("LANG=C /sbin/ifconfig"):lines ()())
   eth0      Link encap:Ethernet  HWaddr 00:1f:d0:55:4c:52  

-Miles

-- 
Everywhere is walking distance if you have the time.  -- Steven Wright