Pcornel
Automation · Scripting

Script Troubleshooting

Cheat sheet · https://pcornel.dk/topic.php?topic=5227

Back to the Topic

Answer

Script troubleshooting checks the input and how the script was called, the runtime and its version, the control flow, dependencies and external commands, and whether the target changed as expected — keeping logs and output before changing anything.

Remember

  • Symptom ≠ root cause; a final error can be downstream of an earlier input, dependency or control-flow failure.
  • Works interactively ≠ works in scheduler/service context; identity, environment, working directory and PATH can differ.
  • Adding retries ≠ fixing the failure; retries can hide deterministic defects or duplicate side effects.
  • Temporary script success ≠ durable fix; the original target outcome and adjacent regressions must be verified.

First checks

  • bash -x script.sh — trace execution
  • Set-PSDebug -Trace 1 — PowerShell trace
  • python3 -m pdb script.py — Python debugger

Commands

bash -n <script.sh>
Read-only/validation observation for Bash parser/syntax result without executing the script body.

Verify in this order

failure → reproduce → trace → fix → test

Where it usually breaks

A changed symptom or successful rerun proves only the observed path changed; root cause is not closed until the first failed boundary is explained and the original target outcome remains correct under regression checks.

Script/input → command/module binding → local/remoting session → request accepted → command result → target object read-back → effective runtime state → workload.

Script Troubleshooting scripting boundary map

BoundaryHealthy evidenceSuspicious evidence
Input / runtimeEffective inputs, runtime, working context and dependency versions are explicitHidden defaults, stale environment, wrong interpreter/path or unvalidated input
Logic / executionBranch/function/module decisions and external actions expose per-operation resultsSwallowed failures, shell reinterpretation, blind retries or last-result-wins behavior
Result / proofExit/exception/log evidence is correlated with independent target read-backProcess success or printed output treated as target success
Recovery / troubleshootingFirst failed boundary is preserved, changed minimally and retestedRandom edits, catch-all suppression or evidence destroyed before diagnosis

Read-only verification commands unless stated otherwise. Confirm syntax for your platform and release. Full reference: https://pcornel.dk/topic.php?topic=5227

Confirmation

Confirm action

Continue?