Skip to content

Execute Remote Script(s)

Overview

rTerm allows clients to execute scripts remotely, which can help automate daily tasks. In this example we will setup a simple task and trigger it remotely.

Prerequisites

  • rTerm Agent and CLI installed on the server/client
  • SSH public key is on the server; private key on the client

Setup Remote Script

  1. Remote in to the server
  2. Make sure the directory ~/rterm/actions exists
  3. Change directory in to that directory (e.g. cd ~/rterm/actions)
  4. Open an editor and edit rt-example.sh (e.g. nano rt-example.sh)
  5. Type touch /tmp/new-example-file and save the file
  6. Make the new file executable (e.g. chmod +x rt-example.sh)

Obtain the Server rTerm Device Id

  1. Remote in to server
  2. Run cat ~/.rterm-agent.deviceId to display the device id
  3. Save this device id somewhere on the client machine

Trigger the Script Remotely

  1. Open a terminal and go to the rTerm directory (e.g. cd ~/rterm)
  2. Run the following command below, replacing the device id from the previous step
~/rterm/rterm-cli --peerDeviceId <deviceId> --execCommand "~/rterm/actions/rt-example.sh" --noStdin

Notes:

  • In this example, we used a script in the ~/rterm/actions folder, but a script in any location can be used.
  • When using ~ this represents the home directory for the rTerm Service account. Depending on your setup, you many need an absolute path.
  • Many of these rterm-cli commands can be put in to a bash script to automate actions across multiple servers.