In versions prior to 4D v11 SQL the command Current machine owner returned the current owners short user name on Mac OS X. On Mac OS X that command now returns the current owners long name, as set in the current user account on the machine.
To acquire the short name for the current user, in Snow Leopard, the method below accomplishes that task using LAUNCH EXTERNAL PROCESS and the Mac OS X UNIX utility "id."
If you call LAUNCH EXTERNAL PROCESS and just use the command id you'll get a very long string with all the ID numbers and names for the current user, as shown below:
uid=501(<short user name>) gid=20(staff) groups=20(staff),204(_developer),100(_lpoperator), 98(_lpadmin),80(admin),61(localaccounts),12(everyone),402(com.apple.sharepoint.group.1), 401(com.apple.access_screensharing)
To acquire just the (<short user name>) part of the string you'll add the utility option "-un". The method below accomplishes the task.
If (True) If (False) //***************************************************************************** // // Current_Machine_UserID // // Purpose: To return the Mac OS X current users name. // // From Terminal Man page: The "id" utility displays the user and group names // and numeric IDs, of the calling process, to the standard output. // If the real and effective IDs are different, both are displayed, // otherwise only the real ID is displayed. // // Option: -un Display the name of the user instead of the number. // // $0 - TEXT - current users name // //***************************************************************************** End if C_TEXT($MethodName_T) $MethodName_T:=Current method name //===================== Declare Variables ================================== //method_parameters_declarations C_TEXT($0) //----------------------------------------------------------------------------- //method_wide_constants_declarations //----------------------------------------------------------------------------- //local_variable_declarations C_TEXT($In;$UserName_T) End if //====================== Initialize and Setup ================================ //======================== Method Actions ================================== LAUNCH EXTERNAL PROCESS("id -un";$In;$UserName_T) // The "whoami" utility has been obsoleted by the "id" utility, and is equivalent to "id -un". // //LAUNCH EXTERNAL PROCESS("whoami";$In;$UserName_T) // Because the Username is returned with an line ending character // $UserName_T:=Substring($UserName_T;1;Length($UserName_T)-1) //======================== Clean up and Exit ================================= $0:=$UserName_T |