#2580 Trying to Capture Out Put Stream from a Process

JohnNuccio Thu 8 Dec 2016

using util

      class ipconfig
      {
         const Str commands := "ipconfig";

    Void main(){
  proc := Process()
                proc.command = Str[commands]
                proc.in = Env.cur().in
                proc.run
  proc.join
  error := proc.err
  //OutStream? err := Env.cur().err
  //proc.out
  test := proc.in.readAllLines
                echo(test)

         }	
             }

How do I capture the result?

SlimerDude Thu 8 Dec 2016

Hi John,

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)

JohnNuccio Thu 8 Dec 2016

Thanks SlimerDude, this worked perfectly.

Login or Signup to reply.