Skip to content
CLI tools

s7commctl

Siemens S7 command-line client for ISO-on-TCP (port 102).

Install

Linux and macOS

curl -fsSL https://get.otfabric.io/s7commctl | sh

Windows (PowerShell)

irm https://get.otfabric.io/s7commctl.ps1 | iex

CI, containers and device images

curl -fsSL https://get.otfabric.io/s7commctl | env OTF_UNMANAGED_INSTALL=/usr/local/bin sh

One static binary for Linux (x86-64, ARM64, ARMv7), macOS (Intel, Apple silicon) and Windows (x86-64, ARM64), with no runtime to install. The installer checks the release's SHA-256 checksum, installs per user without sudo, and upgrades in place when you run it again. Pin a release withOTF_VERSION. All install options. To build from source: make build in a checkout.

First commands

# Find S7 devices on a subnet, as JSON
s7commctl discover --cidr 192.168.1.0/24 --format json

# Which rack and slot values does the PLC accept?
s7commctl probe rackslot --ip 192.168.1.10 --format table

# Read 16 bytes from data block 1
s7commctl read --ip 192.168.1.10 --area DB --db 1 --offset 0 --size 16 --format hex

# List the blocks on the PLC
s7commctl list blocks --ip 192.168.1.10 --format table

# Write an INT, which needs an explicit --dangerous
s7commctl write --ip 192.168.1.10 --area DB --db 1 --offset 0 --type int --value 123 --dangerous

The s7commctl guide walks through every command group, connection option and safety rule.

For scripts, CI and containers

s7commctl is as easy to read for a pipeline as for a person. It follows the same conventions as every OT Fabric tool, so a script written for one protocol carries over to the next.

The exit-code table
CodeMeaning
0Success
1Findings: the command completed and its result reports problems, such as a file that does not validate or a diagnosis with a failing check
2Usage: unknown command or flag, a missing argument
3Invalid input: a flag value, a file or a combination that does not make sense. Nothing was sent
4Transport: the connection could not be made, or was lost
5Timeout: the device did not answer in time
6Protocol: the device refused the request, or broke the protocol
7Partial success: a valid result was written, and it holds failures
8Unsupported: the device, or this platform, does not support what was asked
9Permission: the device or the operating system refused, such as raw-socket access without the capability
10Output or internal error
130Interrupted by Ctrl-C or SIGTERM before a result

Each tool uses the codes that apply to it; a code never changes meaning between tools.

In a Dockerfile

FROM debian:bookworm-slim
RUN apt-get update \
 && apt-get install -y --no-install-recommends ca-certificates curl \
 && curl -fsSL https://get.otfabric.io/s7commctl \
    | env OTF_UNMANAGED_INSTALL=/usr/local/bin sh \
 && rm -rf /var/lib/apt/lists/*
ENTRYPOINT ["s7commctl"]

Scripts, CI and containers has GitHub Actions and GitLab CI examples and shows how to use a simulator as a test fixture.

Protocols

The README on GitHub has the full feature list, examples and changelog.

go-s7comm

Siemens S7 client: read and write DBs, inputs, outputs and markers, discovery and SZL diagnostics.

go get github.com/otfabric/go-s7comm

go-cotp

COTP TP0 transport service over RFC 1006, plus a full X.224 TPDU codec.

go get github.com/otfabric/go-cotp

go-tpkt

TPKT framing for RFC 1006 and RFC 2126 transport profiles.

go get github.com/otfabric/go-tpkt

snap7-interop

Fixture-driven Snap7 servers (native and pure Python) for testing S7 clients.