I occasionally need to customise MATLAB scripts depending on the machine it is being run on. I usually use the following command to grab the computer name:
char(getHostName(java.net.InetAddress.getLocalHost)
This returns a computer name in most cases. However, my laptop (a MacBook) varies depending on which network I am connected to.
Is there a way of retrieving some sort of unique identifier about the computer that does not change depending on the network it is connected to?
Update: I forgot to mention that I am looking for a solution that is OS independent. I need to find a command that works whether on Mac, PC or Linux.
A good identifier that is independent of network is the MAC Address
(nothing to do with macbook). Every computer has a unique MAC Address. You can get it with this command on MATLAB:
system('ifconfig en0 | grep ether')
You will get something like that on the output:
ether 80:e6:50:28:76:d0