Search code examples
cmdoutputstreamfantom

How to capture Process output in Fantom?


How do I capture the stream that is being created for the Process? See the limited Fantom documentation for Process: http://fantom.org/doc/sys/Process

class Ipconfig {

   Void main() {
     proc := Process()
     proc.command = Str["ipconfig"]
     proc.in = Env.cur().in
     proc.run
     proc.join
     test := proc.in.readAllLines
     echo(test)
   }
 }

Solution

  • It looks like you're mixing up your inputs and outputs. You want to set and capture the output for the process, like this:

    buf := Buf()
    
    Process() {
        command = Str["ipconfig"]
        out = buf.out 
    }.run.join
    
    outStr := buf.flip.readAllStr
    echo(outStr)