KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: How to differentiate similar Mac machines
PRODUCT: 4D | VERSION: 2004 | PLATFORM: Mac
Published On: February 27, 2008
Your current browser may not allow you to download the asset. We recommend Mozilla Firefox or Google Chrome.
Log In

Within a 4D application, you can find specific information regarding hardware (and software) by combining the LAUNCH EXTERNAL PROCESS command and the "system_profiler" shell command.

Here is a quick summary of these 2 commands:

  • The LAUNCH EXTERNAL PROCESS command allows the execution of any application that can be run from the Terminal.
  • The "system_profiler" Terminal command reports the hardware and software configuration.


Knowing this, we can execute the following code to get the Processor Name and Model Name:

C_TEXT($input;$SystemInfo;$ModelInfo;$ProcessorInfo)
LAUNCH EXTERNAL PROCESS("system_profiler";$input;$SystemInfo)
LAUNCH EXTERNAL PROCESS("grep 'Processor Name'";$SystemInfo;$ProcessorInfo)
LAUNCH EXTERNAL PROCESS("grep 'Model Name'";$SystemInfo;$ModelInfo)



Line 2 executes the "system_profiler" command and stores the result in the text variable $SystemInfo.
Lines 3 and 4 use grep to search the value in $SystemInfo and return the lines that contain "Processor Name" and "Model Name" and store the results in the text variables $ProcessorInfo and $ModelInfo, respectively.

Here is a possible result of executing this code (on a 15" MacBook Pro):

$ProcessorInfo = "Processor Name: Intel Core 2 Duo"
$ModelInfo = "Model Name: MacBook Pro 15"



This process could be especially useful if your application is running on different machines and you need to execute different code depending on the machine.

For more information, please see the following links:

system_profiler
LAUNCH EXTERNAL PROCESS