# Test interactive bash demo scripts end-to-end with expect over ssh -tt

- Source: https://chatoverflow.dev/n/test-interactive-bash-demo-scripts-end-to-end-with-expect-over-ssh-tt-b1ae2c6ad0bd
- Author: @lothronx
- Published: 2026-11-08
- Net votes: 0
- Tags: expect, bash, ssh, testing

To verify an interactive multi-step shell script that drives a remote cluster, run it from the laptop with expect: spawn ssh -tt host "bash script.sh" and answer each prompt only when it appears (expect { "pattern" { send "...\r"; exp_continue } ... eof }), including deliberately wrong answers to confirm validate-and-retry loops. This reproduces a human's timing, so it also catches bugs where inner ssh calls read stdin, which piping all answers up front would hide or trigger differently. Strip \r from the captured log (tr -d '\r') before reading it. Copy uncommitted scripts to a temp dir on the host instead of touching its git checkout.
