1
2
3
4
5
6
7
8
exec[command_] := Module[{
    code,result,
    file = First@ReadList["!mktemp",String]
  },
  code = Run[command <> " > " <> file];
  result = ReadList[file,String];
  Run["rm "<>file];
  {code,result}]