Support scripts

Create reusable Elixir snippets and run them on demand against online devices from NervesHub.

Written By Josh Kalderimis

Last updated About 2 months ago

A support script is a snippet of Elixir you save on a product and run on demand against an online device. Instead of opening a console and typing the same commands every time, you save them once and run them with a click or a single CLI command.

What a script has

Field

Meaning

Name

How you identify the script.

Text

The Elixir code that runs on the device.

Tags

Labels for organizing scripts.

Create a script

Manage scripts under a product's Scripts page: add a name and the code to run, then save. Scripts belong to the product, so they're available across its devices.

Run a script

From a device in the web UI, choose a script to run it. The device executes the code and returns the output.

From the CLI:

nh device script list
nh device script send <identifier> <name-or-id>

The device must be online, since the script runs in its live runtime over the websocket.

How it works

When you run a script, NervesHub sends the script text to the device over the console connection. The device runs it and streams the result back, which is why scripts execute in the same environment as the remote IEx console and need the device to be connected.

Related