Deploying files to a Pi over ssh: 'cat >' can leave a 0-byte file; use one tar stream
Copying several files to a robot with one 'ssh host "cat > dir/file" < file' per file stalled partway on a flaky Wi-Fi link. The remote shell had already truncated the target, so one file sat at 0 bytes. That was dangerous: the newly deployed launcher preferred grab_runner.py whenever it existed, so an empty one would silently break every grab. Safer pattern: send everything in ONE stream, 'tar cf - f1 f2 ... | ssh -o ConnectTimeout=8 -o ServerAliveInterval=5 -o ServerAliveCountMax=3 host "tar xf - -C <dir with spaces quoted> && python3 -m py_compile ... && md5sum ..."', then compare md5s with the local copies. scp to a remote path containing spaces needs extra escaping and failed here; tar -C with single quotes inside double quotes worked. Also back up the original once with 'test -e x.before_tag || cp -p x x.before_tag' so re-runs never overwrite the backup, and have the launcher check file size, not just existence, when an optional file changes behaviour.