Command Line Tool
Controlling CaptureGRID from a terminal or script
CaptureGRID includes capturegrid6ctl, a command line tool for controlling a
running copy of the app. It is useful when the app has no screen to work
with, such as a node running as a background service on Linux, and for
automating setup tasks from a script.
With it you can:
Check the app’s version, uptime, free disk space and camera count
Activate or deactivate the license
View and change options, such as the photo download folder
List cameras, and ask the app to look for newly connected ones
Watch events from the app as they happen
Send any External API request
Quit the app
Installing and Running
The tool is installed together with the app, so there is nothing extra to install. How you run it depends on your platform:
Platform |
Command |
|---|---|
Windows |
|
macOS |
|
Linux |
|
The examples on this page use capturegrid6ctl; substitute the command for
your platform.
The tool talks to the app over the External API, so the External API
must be enabled. Turn it on in the External API tab of the Options
window, or start the app with the --api command line option (see
Linux). If the app can’t be reached, the tool says so:
> capturegrid6ctl status
error: cannot connect to tcp://127.0.0.1:54544
Is CaptureGRID running with the External API enabled? Turn it on in
Options > External API, or start CaptureGRID with --api.
Ways of Using It
The tool can be used in three ways.
Run a single command by giving it on the command line. The tool runs the command, prints the result and exits:
> capturegrid6ctl status
Version 6.8.0 (linux)
Computer node-01
Uptime 2h 14m
Disk free 412.5 GB
Download dir /data/photos
Cameras 4
Photos 0
Start an interactive shell by running the tool with no command. The shell
keeps a history of the commands you type, and the Tab key completes
command names, option names and request names. Type exit or press
Ctrl-D to quit:
> capturegrid6ctl
capturegrid6ctl 6.8.0 - talking to CaptureGRID at tcp://127.0.0.1:54544. Type 'help' for commands.
capturegrid> cameras
KEY NAME MODEL STATUS
Canon|EOS R6|012345678901 Front Canon EOS R6 Ready
...
capturegrid> exit
Run a script by piping a file of commands into the tool, one command per
line. Blank lines and lines starting with # are ignored. The script stops
at the first command that fails:
> capturegrid6ctl < setup.txt
For example, a setup.txt that prepares a new node:
# Prepare a new capture node
license activate ABCD-EFGH-IJKL-MNOP
download-dir /data/photos
options set AutoConnect true
cameras detect
Commands
Command |
Description |
|---|---|
|
Show the app’s version, uptime, free disk space, download folder, and the number of cameras and photos. |
|
Activate the license with an activation code. Any license already active on the computer is deactivated first. |
|
Deactivate the license on the computer. |
|
Show all options and their current values. |
|
Show the value of one option. |
|
Change an option. |
|
Show the photo download folder, or change it when a path is given. |
|
Change an internal config value. Only use this when advised by Kuvacode support. |
|
List the cameras, with their key, name, model and status. |
|
Ask the app to look for newly connected cameras. |
|
Print events from the app as they happen, until Ctrl-C is pressed. |
|
Send any External API request and print the reply. |
|
Quit the app. |
|
List the commands, or show details of one command. |
Changing Options
Option names are not case-sensitive, and the value you give is converted to
the option’s type. Options that are on or off accept true/false, as well
as yes/no, on/off and 1/0. After changing an option, the
tool reads it back from the app to check that it was applied:
> capturegrid6ctl options set autoconnect on
AutoConnect = true
download-dir is a shortcut for the DownloadPath option. A relative path,
or one starting with ~, is turned into a full path, so this sets the
download folder to the photos folder inside the current one:
> capturegrid6ctl download-dir photos
When the app is running on another computer, the path must be given in full.
Watching Events
watch prints a line for each event the app publishes, such as a photo
being taken or a camera changing state. To see only some events, name them —
the start of a name is enough, so watch camera photo shows only
CameraUpdated and PhotoUpdated events.
The events are CameraUpdated, LiveviewUpdated, NodeUpdated,
OptionsUpdated, PhotoUpdated and RelayCustomText. Live view frames
are large and very frequent, so LiveviewUpdated is only shown when you ask
for it by name.
Sending Any Request
send gives access to every request the External API supports, including
ones without a command of their own. The fields of the request are given
either as one JSON object, or as KEY=VALUE pairs:
> capturegrid6ctl send SetSequenceNum PhotoSequenceNum=10
> capturegrid6ctl send SetSequenceNum '{"PhotoSequenceNum": 10}'
A value is read as JSON when it can be (true, 42, "text"), and as
text otherwise. The reply from the app is printed as JSON. The full list of
requests and their fields is in the External API documentation:
https://github.com/kuvacode/smartshooter-api/blob/v6/external_api.rst
Options
These options go before the command:
capturegrid6ctl [options] [command ...]
Option |
Description |
|---|---|
|
The app’s request endpoint. The default is |
|
The app’s event endpoint, used by |
|
How long to wait for a reply from the app. The default is 5 seconds. |
|
Print the app’s replies as JSON, for use by other programs. |
|
Show the tool’s version and exit. |
|
Show help and exit. |
The endpoints can also be set with the CAPTUREGRID6CTL_ENDPOINT and
CAPTUREGRID6CTL_EVENTS environment variables.
Controlling Another Computer
By default the tool controls the app on the same computer. To control an app
on another computer, first open up its External API endpoints to the network
in the External API tab of its Options window (see
External API), then give its address with --endpoint:
> capturegrid6ctl --endpoint tcp://192.168.1.52:54544 status
Using It in Scripts
The tool’s exit status tells a script whether the command worked:
Status |
Meaning |
|---|---|
|
The command succeeded. |
|
The app reported that the command failed. The error message gives the reason. |
|
The command was not used correctly, such as an unknown command or option, or a value of the wrong type. |
|
The app could not be reached, or did not reply in time. |
Errors are printed to standard error, and results to standard output. Use
--json when another program will read the output.