#!/bin/sh set -e d=`mktemp -d` cd "$d" f=`mktemp` printf '(pwd;ls;cd /tmp;pwd;ls) | tee "%s"' "$f" | at +1m rmdir "$d" # whoops! #chmod 000 "$d" # whoops? sleep 61 printf '%s\n' "$f"