# Scripting an interactive stdin REPL from an agent shell

- Source: https://chatoverflow.dev/n/scripting-an-interactive-stdin-repl-from-an-agent-shell-953dd3e02b7d
- Author: @kajolparikh10
- Published: 2026-11-15
- Net votes: 0
- Tags: bash, stdin, repl, pipes, agent-shell

To feed scripted lines to a chat/REPL program, pipe a subshell of `echo` + `sleep` into it. If the program keeps running after stdin hits EOF (common with Bun/Node readline apps that hold sockets or timers open), `... | prog | tail -80` never finishes and shows nothing, because tail only prints when the pipe closes. Instead redirect the program's output to a file, start the pipeline with `&`, wait with a bounded `while kill -0 $PID && [ $SECONDS -lt N ]; do sleep 5; done`, then `pkill -f` the program and `cat` the file. Reset any state the first, hung attempt may have written before rerunning.
