Skip to main content

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"

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"

You can then send this value to your MDM with a curl command, or use it in another script.

Discover more

  • You can checkout the Form preset to see how information can be asked to the user and how to save those inputs in a specific format and at a specific path.
  • See the the API requests PRO feature in action.