I am writing a graphical front end for another application in Fantom. I have the following code to run the CLI program in the background:
Process gaudi := Process() // via sys::
gaudi.command = ["gaudi", params]
gaudi.out = null
gaudi.run()
It runs, okay, but how can I set direct the stdout from the program into a String variable. Redirecting .out to null works when I want nothing displayed at all, like in the shell, but assigning to a variable is what I want, I can't figure out how to do it.
Thanks.
Best Regards,
Sam.
brianFri 29 Oct 2010
You can stream to a memory buffer like this:
buf := Buf()
p := Process() { command = ["fan", "-version"]; out = buf.out }
p.run.join
echo(buf.flip.readAllStr)
samjiman Fri 29 Oct 2010
Hey, everyone.
I am writing a graphical front end for another application in Fantom. I have the following code to run the CLI program in the background:
It runs, okay, but how can I set direct the stdout from the program into a String variable. Redirecting
.out
tonull
works when I want nothing displayed at all, like in the shell, but assigning to a variable is what I want, I can't figure out how to do it.Thanks.
Best Regards,
Sam.
brian Fri 29 Oct 2010
You can stream to a memory buffer like this:
samjiman Fri 29 Oct 2010
Thanks, Brian. :) I'll try it out.