Category filter

Fix common issues while executing custom scripts on Mac

Case 1:

Unable to execute scripts. Argument values are not parsed as expected.

While executing the scripts, the argument values are not parsed to the corresponding variables used in the shell scripts. Hence, the scripts are not executed successfully.


Failed to parse the argument value as a single entity as it is enclosed in quotes when passed from the Hexnode portal.

For instance,

The shell script to add a user to the device:

And, if a value “Adam Johns” is passed as $1, it is not considered a single component but two different components, “Adam” and “John”. Hence, the values might not be parsed correctly.


Always enclose the argument value in single quotes if it contains two or more words separated by spaces while passing.

Case 2:

Running the Homebrew commands as scripts from the Hexnode portal generates the error “Running Homebrew as root is extremely dangerous and no longer supported. As Homebrew does not drop privileges on installation, you would be giving all build scripts full access to your system.”


By default, Hexnode executes the script command at the root level.


Homebrew commands need not be executed at the root level. In cases where you do not want specific commands to be run at the root level, you can explicitly execute them at the user level. The following command helps to get the logged-in details of the current user on the device:

currentUser=$( echo "show State:/Users/ConsoleUser" | scutil | awk '/Name :/ { print $3 }' )

Include the above command on the script. Then proceeding with the necessary operation as the currentUser helps you run it at the given user level.

For example, the below command changes the default dock orientation of the given user to the value Left.

currentUser=$( echo "show State:/Users/ConsoleUser" | scutil | awk '/Name :/ { print $3 }' )

sudo -u "$currentUser" defaults write orientation left

Case 3:

Homebrew command raises the “Command not found” error.


There might be an issue with the Homebrew path variable.


Specify the full path (default location of Homebrew) for the path variable in the scripts.

For example:

Case 4:

When a Python script is executed on macOS devices, the error “Script execution failed. Verify the binary path and try again!” may be produced.


When choosing a script file to be executed, the Binary path field is auto-filled according to the format of the file. When a Python file is uploaded or selected from the Hexnode repository, /usr/bin/python is auto-filled as the binary path. This path may be insufficient in some instances.

Until macOS version 12.3, Macs used to have Python pre-installed in them. In later versions, Python has to be manually installed in order to execute a Python script on the device. But when installed manually, the binary path will be different.


Execute the following command to get the required binary path:

Re-execute the Python script after replacing the auto-filled Binary path with the output of this command.

python binary path

  • Troubleshooting Guides