필터 지우기
필터 지우기

How to get the account username using MATLAB?

조회 수: 400 (최근 30일)
Chuck
Chuck 2016년 2월 21일
편집: Francisco Sacchetti 2022년 10월 12일
I am talking about the username, not the host or computer name. For instance, if you are working on Google Drive, your Drive folder will be under C://users/USERNAME. I am talking about that USERNAME part. :)
  댓글 수: 1
Ramnath Natarajan
Ramnath Natarajan 2022년 7월 19일
If u run command prompt (windows button + R ------> type 'cmd' and press 'Enter'), the default command line shows the username (image below)

댓글을 달려면 로그인하십시오.

채택된 답변

Chuck
Chuck 2016년 2월 21일
편집: Chuck 2016년 2월 21일
Found it! :) It's extremely straight-forward.
Let me post it here for those who are struggling to find:
getenv('username')
  댓글 수: 4
Walter Roberson
Walter Roberson 2019년 3월 29일
Which operating system, Ram? The solution for Windows is likely to be quite different than Linux or Mac.
Walter Roberson
Walter Roberson 2019년 3월 29일
Note that the solutions might be different for network login situations.
For Mac it looks like you could use
[status, fullname] = system('id -F')
but watch out as it will include line terminator

댓글을 달려면 로그인하십시오.

추가 답변 (2개)

Image Analyst
Image Analyst 2016년 2월 21일
To get the folder, you can use
userProfile = getenv('USERPROFILE');
  댓글 수: 2
Ashish Sheikh
Ashish Sheikh 2020년 3월 16일
I guess this is for Windows .. Do you by chance know how to get the userprofile on linux and mac ?
Walter Roberson
Walter Roberson 2020년 3월 16일
Mac and Linux do not have user profile. See https://www.mathworks.com/matlabcentral/answers/269214-how-to-get-the-account-username-using-matlab#comment_344298

댓글을 달려면 로그인하십시오.


Eran
Eran 2022년 1월 20일
편집: Image Analyst 2022년 7월 19일
userName = char(java.lang.System.getProperty('user.name'))
userName = 'mluser'
  댓글 수: 4
Steven Lord
Steven Lord 2022년 10월 11일
@Francisco Sacchetti What are you hoping or planning to do with that information in a web app?
Francisco Sacchetti
Francisco Sacchetti 2022년 10월 12일
편집: Francisco Sacchetti 2022년 10월 12일
I found a path:
  • Enable SSL on the server. For more information, see Enable SSL.
  • Enable authentication on the server. For more information, see Authentication.
And then you can use compiler.UserInfo() to get the infromation of the user.
I want to first to track who is using the app, also it will be nice to adapt the app depending on the users.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Manage Products에 대해 자세히 알아보기

제품

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by