Dataplicity Developer Hub

Dataplicity Documentation

Here you'll find announcements for new features and comprehensive guides to help you integrate Dataplicity into your Raspberry Pi projects.

Get Started    Announcements

Command line interface for Porthole

A useful feature of Dataplicity's Porthole is its Command Line Interface.

A Command Line Interface (CLI) provides all the functionality that a user has when using the graphical interface of Porthole. The biggest benefit of a CLI however, is that a user can automate many operations that would have to be done by hand otherwise. The ability to run porthole from terminal is also useful when a user connects via SSH to his Windows PC. Others might simply prefer the terminal window experience rather than using graphical interface.

How to use

All available commands that Porthole supports can be seen when you simply type porthole into the command prompt.

To open Windows Command Prompt type in "cmd" into the search bar near the start menu.

Then in terminal window run:

porthole

In response you will get all available commands with a description and how to use them:

Usage:

porthole account
Displays info about current user.

porthole devices
Lists all available devices.

porthole forwards
Lists all assigned forwards.

porthole account:login [login] [password]
To log in with provided credentials.

porthole account:setkey [auth token]
To re-use existing user session.

porthole account:logout
To log out.

porthole devices:status [device ID]
To check the online status of specified device. Device ID is optional, if not provided the list of device statuses will be displayed.

porthole devices:reboot [device ID]
To reboot specified device.

porthole devices:command [device ID] [command]
To issue a command for specified device.

porthole devices:terminal [device ID]
To start a terminal session with specified device.

porthole forwards:add [local port] [device ID] [remote port]
To add a forward where local port is this machine port and remote port is a port of external device to forward local port to.

porthole forwards:delete [local port]
To remove forward assigned to specified local port.

Running commands

Let's take a couple of the above commands to see how you can interact with Porthole.

Account details

Firstly let's have a look at the account that you're logged in with:

porthole account

CLI Output:

Getting profile...
Signed in as User (User@dataplicity.com)

Forwarded devices

Now let's see the list of forwarded devices, this is the same one you see in the graphical interface:

porthole forwards

CLI Output:

Executing commands

Let's issue an ls command directly to the first device on the list:

porthole devices:command 11111111-1111-1111-1111-111111111111 ls

CLI Output:

bin dev home lib man mnt proc run srv tmp var
boot etc lost+found media opt root sbin sys usr

Pretty cool but let's have a look at running something like htop:

porthole devices:command 11111111-1111-1111-1111-111111111111 htop

CLI Output:

Executing multiple commands

Now the biggest advantage of the CLI. Let's check the contents of /home/pi directories on two separate devices. This involves porthole command combined with some Windows batch scripting.

for %x in (
11111111-1111-1111-1111-111111111111
22222222-2222-2222-2222-222222222222
) do (
porthole devices:command %x ls /home/pi 
)

CLI Output:

Command line interface for Porthole


Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.