Here's an example using a temp-file:
(The CaptureCommandOutput function, specifically. The rest can be ignored.)