Scripting (Beta)

Supported in version 3.34.4 or greater of app.remote.it or Desktop application.

Scripting is a feature that allows you to run a script unattended (written in any interpreted language you have installed on your Operating System) on any number of devices with a Linux or Windows based operating system.

This is useful when you have a repetitive action that you would like to perform on one or more devices. For example, you could fetch information from the device such as available disk space, memory and send it to your backend, show them on status columns or other custom attribute fields on Remote.It OR reboot your devices. Your devices do not need to be all be online at the same time. You can choose individual devices or choose devices based on tags applied to them.

Scripts

Scripts are the files that will be sent to the selected device(s) and run on them.

To upload or modify a script: You must be the account owner or if you belong to an organization, have administrator permission.

To view the list of scripts, view a script, run a script, or cancel a script run: You must be able to upload a script or have the system role of Manager or have a custom role with with Script.

 

Create a Script Run

It is best to run a job on a max 50 devices or less at a time whether or not they are tagged or individually selected.

From the Device List Page

  1. Click the "Show Select" checkbox in the upper right corner. Then select the devices you wish to run the script against
  2. Either select "Choose Script" or "Add Script" once you have selected your devices.
    1. Choose Script - Select the script
    2. Add Script - Upload a script or type your script inline. Add a name and optionally a description
  3. Click "Save and Run" to run the script right now OR "Save" to come back and run it at a later time.

From the Scripting Page

  1. Click Scripting on the left navigation
  2. Either select an existing script or Add Script
    1. Choose Script - Select the script
    2. Add Script - Upload a script or type your script inline. Add a name and optionally a description
  3. Select the devices
    • Selected Devices will take you to the device list where you can select devices and then click "Continue"
    • Tags - Select the Tags, or combination of tags with any or all as a match modifier. For example, if I selected tags of "Pi" and "Support" and match of "any", the script would run against devices which had the tag "Pi" or "Support" or both "Pi" and "Support". Otherwise, if I selected tags of "Pi" and "Support" and match of "all", the script would only run against devices which had both "Pi" and "Support" tags.
  4. Click "Save and Run" to run the script right now OR "Save" to come back and run it at a later time.

From a Device Page

  1. From any device detail page, you can also run a script against that device if you have scripting permissions.
  2. Click on "Script" under the device name.
  3. Either select an existing script or Add Script
    1. Choose Script - Select the script
    2. Add Script - Upload a script or type your script inline. Add a name and optionally a description
  4. Click "Save and Run" to run the script right now OR "Save" to come back and run it at a later time.

Script Runs

Script run execution is sent to all devices by separate processes at nearly the same time. The Remote.It server will attempt to send a job to a given device 26 times with an exponential backoff that will end after 1.5 days. This will allow for a device that might be offline temporarily to still receive a script job.

Creating Scripts

Remote.It allows you to write scripts in any language your host operating system supports because the script is run just like any other executable script on your machine. This means you can write in bash, Python, Ruby, Node, etc., assuming you have the interpreter installed on your system. Scripts are executed as root.

We recommend that you write your script and test it on a device before you try to run it on multiple devices.
Example of a script getting the hostname from the device and setting it as an attribute on the device
#!/bin/bash

Attribute() {
ATTRIBUTE_NAME="$1"
ATTRIBUTE_VALUE="$2"

# Send the data to the API, including jobDeviceId and attributeName in the URL
curl -X POST "https://${GRAPHQL_API_PATH}/job/attribute/$JOB_DEVICE_ID/$ATTRIBUTE_NAME" \
-H "Content-Type: text/plain" \
--data "$ATTRIBUTE_VALUE"
}

Attribute hostname "$(hostname)"
After above script is run on this device, the Hostname appears
SCR-20241025-nbsa.png

More example scripts can be found at our github repository and you are encouraged to share your scripts with the community. https://link.remote.it/github/scripts 

Files must be able to be uploaded in 30 seconds. If you need to have larger files, consider hosting at another location such as S3 and having your script fetch them.

Remote.It also has an API for Scripting and other functions if you are developing automation or your own application. See our documentation at https://link.remote.it/docs/api 

Was this article helpful?
0 out of 0 found this helpful