views:

46

answers:

2

Hi Friends,

I made a login script in Perl which has to run on Mac OS X clients and record the Logged in Directory Service user name.

I tried using getlogin() , getpwuid($<) respectively.

Now the problem is that since the login script runs as root on the system when the client logs in, getpwuid($<) always gives me the username as root. When using the getlogin() function, i do get the user name but for the user who logged in previously on the system.

I am using an open directory environment consisting of a Mac OS server.

Any ideas on how to solve this issue?

A: 

Can you just use last? (man page) The log-in names and the duration are already in the wtmp file. I don't think you need to log them yourself.

Yuji
Hi. Last and getlogin() both give the Last user who logged in. This is a Loginhook script
ricky2002
A: 

Are you talking about a loginhook script? If so, it'll get passed the username as an argument, so $ARGV[0] should be what you need.

Gordon Davisson
Hi, yes its a loginhook script. But the thing is the script does not reside on the Client machines. Its on the server, selected under the WorkGroup Manager. How can i pass $ARGV[0] from there?
ricky2002
The script is defined on the server, but actually executes on the client.
Gordon Davisson
Yes, you are correct. That is my exact setup. In the Workgroup Manager, under the Computer Group Preferences, i have selected my Login script. Do i have to pass anything from there? if yes, how
ricky2002