The environment variable COMPUTERNAME exists in Windows, but I dont think the computer name is stored in any environment variables for OSX which is why I resorted to using scutil.
So a hack like this may work on both platforms.
#target photoshop
function getSystemCommandStdout (command)
{
var stdout = "";
var tempFile = new File (Folder.temp + "/temp.txt");
app.system (command + " > " + tempFile.fsName);
if (tempFile.open ("r"))
{
stdout = tempFile.read ();
tempFile.close ();
tempFile.remove ();
}
return stdout;
}
if ($.os.match(/windows/i)) var computerName = getSystemCommandStdout("echo %COMPUTERNAME%");
else var computerName = getSystemCommandStdout("scutil --get ComputerName");
$.writeln(computerName);