getlogin
Returns the current login from /etc/utmp (Unix systems only), if any. If null, use getpwuid . For example:
getpwuid
$login = getlogin || getpwuid($<) || "Intruder!!";
Copyright © 2001 O'Reilly & Associates. All rights reserved.