TIP

How to read Octory inputs file

When you ask information to the end user with an InputComponent, Octory will store the inputs in a file. This file has a default name of Octory_inputs and will be stored at ~/Octory/Octory_inputs.json with a JSON default data format. You can change this behavior by editing the Input section in the configuration file. To change the data format to Plist for example.

The thing is, what should you do with this input file once Octory is terminated? You can send it to your MDM, or use it to locally make some additional configuration. In any case, you might need to read the information it contains. Here are some solutions with the following example JSON or its Plist equivalent.

JSON

{
  "AssetTag": "GT6J8IO",
  "UserRole": "Consultant",
  "Supplies": [
    true,
    false,
    true
  ]
}
Plist
<?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>AssetTag</key>
	<string>GT6J8IO</string>
	<key>UserRole</key>
	<string>Consultant</string>
	<key>Supplies</key>
	<array>
		<true/>
		<false/>
		<true/>
	</array>
</dict>
</plist>

Read the Asset tag

Python script (Plist)

#!/usr/bin/python
import plistlib
plistname = "/path/to/Octory_inputs.plist"
pl = plistlib.readPlist(plistname)

if pl["AssetTag"] != 0:
	tag = pl["AssetTag"]
	print(result))
else:
	print "Not Indicated"

Bash script with defaults (Plist)

#!/bin/bash
if [ -f "/path/to/Octory_inputs.plist" ] ; then
	TAG=$( defaults read "/path/to/Octory_inputs.plist" AssetTag )
else
	TAG="Not Indicated."
fi

echo "$TAG"

Bash script with Scout (JSON or Plist)

if [ -f "Octory_inputs.plist" ] ; then
	if tag=$(scout -i Octory_inputs.plist "AssetTag") ; then
		echo "$tag"
	else
		echo "Not indicated"
	fi
fi

Read the "Supplies" second value

Python script (Plist)

#!/usr/bin/python
import plistlib
plistname = "Octory_inputs.plist"
pl = plistlib.readPlist(plistname)

if pl["Supplies"] != 0:
	supplies = pl["Supplies"]
	if len(supplies) > 1:
		secondSupply = supplies[1]
	print(secondSupply)
else:
	print "Not Indicated"
	

Bash script with Scout (JSON or Plist)

#!/bin/zsh
if [ -f "Octory_inputs.json" ] ; then
	if secondSupply=$(scout -i Octory_inputs.json "Supplies[1]") ; then
		echo "$secondSupply"
	else
		echo "Not indicated"
	fi
fi

You can then send this value to your MDM with a curl command, or use it in another script. Regarding the curl command, this can also be done within Octory with the API requests PRO feature.


Go further