I'm trying to get the computer name through Mac environmental variables. For Windows it work fine. For Mac it just returns null (when using HOSTNAME). I got a list of environmental variable from the terminal and tested a bunch of them. The only ones that seems to work are HOME, USER, and LOGNAME. However, I really need the HOSTNAME. Does anyone know a way to get this? I'm testing on 10.6.7.
For Windows, this works.
Code: Select allvar comp_name=$.getenv("COMPUTERNAME");
For Mac, this doesn't work.
Code: Select allvar comp_name=$.getenv("HOSTNAME");
Mac Environmental Variables
-
Mikaeru
Mac Environmental Variables
ddbell wrote:For Mac, this doesn't work.
Code: Select allvar comp_name=$.getenv("HOSTNAME");
Yes, in Photoshop CS4 under Mac OS X 10.6.8, both $.getenv ("HOSTNAME") and $.getenv ("HOST") return null, although the latter should work since HOST is one of the environment variables listed by the Unix 'printenv' command run in a Terminal window...
Anyway, here is a quick try which works correctly for me, using the Unix 'hostname -s' command:
Code: Select allfunction getSystemCommandStdout (command)
{
var stdout = null;
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;
}
alert (getSystemCommandStdout ("hostname -s").trim ());
HTH,
--Mikaeru
Code: Select allvar comp_name=$.getenv("HOSTNAME");
Yes, in Photoshop CS4 under Mac OS X 10.6.8, both $.getenv ("HOSTNAME") and $.getenv ("HOST") return null, although the latter should work since HOST is one of the environment variables listed by the Unix 'printenv' command run in a Terminal window...
Anyway, here is a quick try which works correctly for me, using the Unix 'hostname -s' command:
Code: Select allfunction getSystemCommandStdout (command)
{
var stdout = null;
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;
}
alert (getSystemCommandStdout ("hostname -s").trim ());
HTH,
--Mikaeru
-
Mikaeru
Mac Environmental Variables
BTW, the following line of code:
Code: Select allalert ("Photoshop environment variables:\r" + getSystemCommandStdout ("printenv"));
should list the "customized" set of environment variables accessible from "inside" Photoshop, compared to what is available from a Terminal window.
Code: Select allalert ("Photoshop environment variables:\r" + getSystemCommandStdout ("printenv"));
should list the "customized" set of environment variables accessible from "inside" Photoshop, compared to what is available from a Terminal window.