How to find MAC address and uids?

Marcin Jurczuk mj-usunto at tkb.pl
Wed Nov 10 13:19:36 CET 2004


On 2004-11-10, Marcin Jurczuk <mj-usunto at tkb.pl> wrote:
> On 2004-11-10, Daniel T. <postmaster at earthlink.net> wrote:
>
>> 1) How can I programatically find the MAC address of the machine? Is it 
>> stored in a file I can look into? (MacOS X)
> What is syntax of this file ??
My Mistake :)
If you have access to /sbin/ifconfig (if MacOS X is FreeBSD based it should 
be in /sbin) you can use something like this:
>>> import os
>>> a=os.popen('/sbin/ifconfig bge0|grep ether').read().replace('\n','').split()[1]
>>> print a
00:30:84:b3:b3:3a
>>>

Important - replace bge0 your card name ...

>
>> 2) If I have a user name in a string how do I get his UID?
>
>>>> import pwd
>>>> pwd.getpwnam('spock')
> ('spock', 'x', 100, 101, '', '/export/home/spock', '/bin/bash')
>>>> pwd.getpwnam('spock')[2]
> 100
>>>>
>
>


-- 
Marcin Jurczuk, NIC-HDL: MJ1679-RIPE



More information about the Python-list mailing list