---
yatl_version: 1
title: Generate command scripts per host
id: 14ft0q0f
created: 2026-01-18T21:40:39.107630Z
updated: 2026-01-27T02:22:15.319486Z
author: Brian McCallister
priority: high
tags:
- server-mode
---

For each host, generate a command script at $output_dir/$host/command:

```bash
#!/bin/sh
# bdsh command wrapper for $host
START=$(date +%s.%N)
echo "running" > $output_dir/$host/status

ssh $SSH_OPTIONS $host '$command' 2>&1
EXIT_CODE=$?

END=$(date +%s.%N)
echo "{\"exit_code\": $EXIT_CODE, \"start\": $START, \"end\": $END}" > $output_dir/$host/meta.json

if [ $EXIT_CODE -eq 0 ]; then
  echo "success" > $output_dir/$host/status
else
  echo "failed" > $output_dir/$host/status
fi
exit $EXIT_CODE
```

This approach:
- Makes runs reproducible (just run `sh command` to replay)
- Captures timing and exit status automatically
- Provides clear status file for client mode to watch

---
# Log: 2026-01-18T21:40:39Z Brian McCallister

Created task.

---
# Log: 2026-01-18T21:40:53Z Brian McCallister

Added blocker: r5tbh396

---
# Log: 2026-01-27T02:20:06Z Brian McCallister

Removed blocker: r5tbh396

---
# Log: 2026-01-27T02:20:20Z Brian McCallister

Started working.

---
# Log: 2026-01-27T02:22:15Z Brian McCallister

Closed: Implemented command wrapper scripts with timing, exit code, and status tracking. Watch mode now shows per-host status (pending/running/success/failed) with colors.
