Get user name from the command line on different platforms

Viewed 5311

Is there a way in MATLAB to get the user name of the user that started the session?

I am interested in solutions for Windows, Linux and Mac OSX. I imagine that if the solutions are platform-specific, both solutions can be integrated as follows:

if ispc
    user_name = % method 1
elseif isunix
    user_name = % method 2
elseif ismac
    user_name = % method 3
end
3 Answers
Related