Execute Command
Octory PRO
Element type: Dictionary
This action make the application execute a command like in the terminal. Those commands will be executed with root rights thanks to the Helper.
Keys
Name | Type | Possible values | Required |
---|---|---|---|
Type | String | ExecuteCommand | Required |
Command | String | - | Required |
Variable | String | - | |
Condition | Dictionary (Condition) | - |
Detail
Type Required
Type: String
Explanation: The type of the action has to be ExecuteCommand
.
Command Required
Type: String
Explanation: The command to execute.
Variable
Type: String
Explanation: When specified, the output of the command will be stored inside a variable with the given name.
Condition
Type: Dictionary (Condition)
Explanation: Allows launch the action only based on a boolean expression.
Example
This action will get the local IP.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<!-- ... -->
<key>ActionSets</key>
<array>
<dict>
<key>Type</key>
<string>Parallel</string>
<key>Triggers</key>
<array>
<string>NextButtonClick</string>
</array>
<key>Actions</key>
<array>
<dict>
<key>Type</key>
<string>ExecuteCommand</string>
<key>Command</key>
<string>ifconfig | grep "inet " | head -n 2 | tail -n 1 | cut -d " " -f 2</string>
<key>Variable</key>
<string>LocalIP</string>
</dict>
</array>
</dict>
</array>
<!-- ... -->
</dict>
</plist>
The next example shows how to save the first configuration profile on the Mac into the variable ProfileIdentifier
. Note that the profile
command requires root rights, which is not a problem since it is executed by the privileged Helper.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<!-- ... -->
<key>ActionSets</key>
<array>
<dict>
<key>Type</key>
<string>Parallel</string>
<key>Triggers</key>
<array>
<string>Termination</string>
</array>
<key>Actions</key>
<array>
<dict>
<key>Type<key>
<string>ExecuteCommand</string>
<key>Command</key>
<string>profiles -P | head -n 1 | cut -d "." -f 3</string>
<key>Variable</key>
<string>ProfileIdentifier</string>
</dict>
</array>
</dict>
</array>
<!-- ... -->
</dict>
</plist>