> ## Documentation Index
> Fetch the complete documentation index at: https://docs.lagerdata.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Binaries

> Manage custom binaries on Lager Boxes

Upload, list, and remove custom binaries on Lagerboxes for use in Python scripts.

## Syntax

```bash theme={null}
lager binaries COMMAND [OPTIONS]
```

## Commands

| Command  | Description                         |
| -------- | ----------------------------------- |
| `add`    | Upload a binary to a Lager Box      |
| `list`   | List custom binaries on a Lager Box |
| `remove` | Remove a binary from a Lager Box    |

***

## Command Reference

### `add`

Upload a binary file to the Lager Box.

```bash theme={null}
lager binaries add BINARY_PATH [OPTIONS]
```

**Arguments:**

* `BINARY_PATH` - Local path to the binary file

**Options:**

* `--box BOX` - Lagerbox name or IP address
* `--name NAME` - Name for the binary on Lager Box (defaults to filename)
* `--yes` - Skip confirmation prompt

**Examples:**

```bash theme={null}
# Upload with default name
lager binaries add ./my_tool --box lab-lager-box

# Upload with custom name
lager binaries add ./rt_newtmgr_v1.2 --name rt_newtmgr --box lab-lager-box

# Skip confirmation
lager binaries add ./firmware_flasher --box lab-lager-box --yes
```

### `list`

List all custom binaries on a Lager Box.

```bash theme={null}
lager binaries list --box BOX
```

Output:

```
Custom binaries on lab-lager-box:
  rt_newtmgr (1.2 MB)
  firmware_flasher (856 KB)
  custom_tool (234 KB)
```

### `remove`

Remove a binary from the Lager Box.

```bash theme={null}
lager binaries remove BINARY_NAME [OPTIONS]
```

**Arguments:**

* `BINARY_NAME` - Name of the binary to remove

**Options:**

* `--box BOX` - Lagerbox name or IP address
* `--yes` - Skip confirmation prompt

**Examples:**

```bash theme={null}
# Remove with confirmation
lager binaries remove old_tool --box lab-lager-box

# Remove without confirmation
lager binaries remove old_tool --box lab-lager-box --yes
```

***

## Storage Locations

Binaries are stored in:

| Location         | Path                                             |
| ---------------- | ------------------------------------------------ |
| Host (Lager Box) | `/home/lagerdata/third_party/customer-binaries/` |
| Container        | `/home/www-data/customer-binaries/`              |

***

## Using Binaries in Python Scripts

Once uploaded, binaries can be called from Python scripts running on the Lager Box:

```python theme={null}
import subprocess

# Call the binary with arguments
result = subprocess.run(
    ['/home/www-data/customer-binaries/rt_newtmgr', 'arg1', 'arg2'],
    capture_output=True,
    text=True,
    timeout=30
)

if result.returncode == 0:
    print(f"Success: {result.stdout}")
else:
    print(f"Error: {result.stderr}")
```

***

## Adding to PATH (Optional)

To call binaries without the full path, modify the Lager Box Dockerfile:

```dockerfile theme={null}
# In box/lager/docker/box.Dockerfile
ENV PATH="/home/www-data/customer-binaries:${PATH}"
```

Then rebuild the container:

```bash theme={null}
lager update --box lab-lager-box --yes
```

Now you can call binaries directly:

```python theme={null}
subprocess.run(['rt_newtmgr', 'arg1', 'arg2'], ...)
```

***

## Examples

```bash theme={null}
# Complete workflow
# 1. Upload binary
lager binaries add ./my_custom_tool --box lab-lager-box --yes

# 2. Verify it's there
lager binaries list --box lab-lager-box

# 3. Use in Python script
lager python ./test_script.py --box lab-lager-box

# 4. Clean up when done
lager binaries remove my_custom_tool --box lab-lager-box --yes
```

***

## Use Cases

### Device Communication Tools

Upload vendor-specific tools for device interaction:

```bash theme={null}
lager binaries add ./vendor_cli --box lab-lager-box
```

### Firmware Tools

Upload custom firmware manipulation tools:

```bash theme={null}
lager binaries add ./sign_firmware --box lab-lager-box
lager binaries add ./encrypt_image --box lab-lager-box
```

### Test Utilities

Upload test-specific utilities:

```bash theme={null}
lager binaries add ./stress_test --box lab-lager-box
lager binaries add ./validate_output --box lab-lager-box
```

***

## Notes

* Binaries must be Linux x86\_64 compatible
* Files are automatically made executable
* Container restart is not required (volume mount)
* File sizes are displayed in human-readable format
* Use `--yes` to skip confirmation in scripts
