in reply to STDOUT to a file

tsk tsk Super Search is your friend

I believe your looking for this

If you want to live dangerous you could use open3 but read the warning. I've been using it heavily and have had only a few problems (mysterious hangs) that I can't even say for sure are from my use of open3 - ( read the entire thread and comments as most of the code there is irrelevant).

coreolyn