How to find MAC address and uids?

D

Daniel T.

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.
 
M

Marcin Jurczuk

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
 
J

James Weatherley

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}'
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top