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
- Remote in to the server
- Make sure the directory
~/rterm/actions
exists - Change directory in to that directory (e.g.
cd ~/rterm/actions
) - Open an editor and edit
rt-example.sh
(e.g.nano rt-example.sh
) - Type
touch /tmp/new-example-file
and save the file - Make the new file executable (e.g.
chmod +x rt-example.sh
)
Obtain the Server rTerm Device Id
- Remote in to server
- Run
cat ~/.rterm-agent.deviceId
to display the device id - Save this device id somewhere on the client machine
Trigger the Script Remotely
- Open a terminal and go to the rTerm directory (e.g.
cd ~/rterm
) - 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.