exec to capture stdout, stderr and code