469,289 Members | 2,090 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,289 developers. It's quick & easy.

How to find MAC address and uids?

I'm writing a script for work and to finnish it, I need two bits of
information which I'm having trouble finding.

1) How can I programatically find the MAC address of the machine? Is it
stored in a file I can look into? (MacOS X)

2) If I have a user name in a string how do I get his UID?

Thanks to anyone that can help.
Jul 18 '05 #1
4 4054
On 2004-11-10, Daniel T. <po********@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 ??
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
Jul 18 '05 #2
On 2004-11-10, Marcin Jurczuk <mj*******@tkb.pl> wrote:
On 2004-11-10, Daniel T. <po********@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
Jul 18 '05 #3
In article <po******************************@news1.east.earth link.net>,
po********@earthlink.net says...
I'm writing a script for work and to finnish it, I need two bits of
information which I'm having trouble finding.

1) How can I programatically find the MAC address of the machine? Is it
stored in a file I can look into? (MacOS X)
$ ifconfig | grep ether | awk {'print $2'}
Note that there may be 0, 1 or many MAC addresses.
2) If I have a user name in a string how do I get his UID?


This gets the uid for 'james':
$ nireport . /users name uid | grep james | awk '{print $2}'
Jul 18 '05 #4
Daniel T. wrote:
2) If I have a user name in a string how do I get his UID?


"man getpwnam" might help you find an answer.
Jul 18 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Phil | last post: by
4 posts views Thread by Arun | last post: by
12 posts views Thread by Souljaz | last post: by
3 posts views Thread by subirs | last post: by
10 posts views Thread by OppThumb | last post: by
2 posts views Thread by frikk | last post: by
1 post views Thread by CARIGAR | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.