exec[command_] := Module[{ code,result, file = First@ReadList["!mktemp",String] }, code = Run[command <> " > " <> file]; result = ReadList[file,String]; Run["rm "<>file]; {code,result}]