Getting User Name through Python

11435
3
Jump to solution
01-25-2012 06:29 AM
JeremyLuymes
New Contributor III
Hi,

I'm writing a python script that will automatically add records to an SDE data base from an excel table.

I was wondering if there is a way to autopopulate the creation user field based on who is running the script. Basically, is there a way to determine what the username of the person logged into the computer is through python.

Thanks,

Jeremy
Tags (2)
1 Solution

Accepted Solutions
RaphaelR
Occasional Contributor II
hi Jeremy,

getpass should do the trick:

import getpass print getpass.getuser()

View solution in original post

0 Kudos
3 Replies
RaphaelR
Occasional Contributor II
hi Jeremy,

getpass should do the trick:

import getpass print getpass.getuser()
0 Kudos
AndrewChapkowski
Esri Regular Contributor
You can also try this:
import os
print os.environ.get( "USERNAME" ) 
0 Kudos
RussellBrennan
Esri Contributor
Something that you might want to look for if you are moving to 10.1 is the new editor tracking capabilities. This will allow the geodatabase to automatically enter certain attributes such as user names when records are updated.
0 Kudos