Skip to content

Non-Interactive Mode Walkthrough

Recording

Non-interactive mode is designed for CI/CD pipelines, automated testing, and scripted operations where no human interaction is required.

Core Flags

Flag Short Description
--non-interactive Run scan without user prompts
--tools -t Comma-separated list of tools to run
--export -e Export format: pdf or html
--output -o Output file path for exported report
--exit-code Return exit code based on results
--json JSON output instead of Rich tables
--quiet -q Suppress all output except errors
--verbose Show full tool output (no truncation)
--only-failures Only show failed tool results

Examples

Basic non-interactive scan

sudo cis-hardening-tool scan --tools lynis --non-interactive

Scan with PDF report export

sudo cis-hardening-tool scan \
  --tools lynis,openscap \
  --non-interactive \
  --export pdf \
  --output /tmp/compliance_report.pdf

CI/CD pipeline with exit codes

# Returns:
#   0 = all tools passed
#   1 = some tools failed
#   2 = all tools failed
sudo cis-hardening-tool scan \
  --tools lynis \
  --non-interactive \
  --exit-code

echo "Exit code: $?"

JSON output for programmatic consumption

sudo cis-hardening-tool --json scan \
  --tools lynis \
  --non-interactive

Output:

[
  {
    "tool": "lynis",
    "status": "Pass",
    "details": "Report: /root/.cis-sentinel/reports/..."
  }
]

Quiet mode (errors only)

sudo cis-hardening-tool --quiet scan \
  --tools lynis \
  --non-interactive \
  --export pdf \
  --output report.pdf

Show only failures

sudo cis-hardening-tool scan \
  --tools lynis,openscap,ciscat \
  --non-interactive \
  --only-failures

Using in Scripts

#!/bin/bash
# Daily compliance scan script
set -e

REPORT_DIR="/var/reports/cis"
DATE=$(date +%Y-%m-%d)
REPORT="$REPORT_DIR/scan_${DATE}.pdf"

mkdir -p "$REPORT_DIR"

sudo cis-hardening-tool scan \
  --tools lynis,openscap \
  --non-interactive \
  --export pdf \
  --output "$REPORT" \
  --exit-code

if [ $? -ne 0 ]; then
  echo "ALERT: Compliance scan detected issues!"
  # Trigger alert, email, webhook, etc.
fi