【问题标题】:How to capture Process output in Fantom?如何在 Fantom 中捕获进程输出?
【发布时间】:2016-12-08 22:00:15
【问题描述】:

如何捕获为流程创建的流?请参阅有限的 Fantom 文档以了解 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)
   }
 }

【问题讨论】:

    标签: cmd outputstream fantom


    【解决方案1】:

    您似乎混淆了输入和输出。您想为进程设置和捕获 输出,如下所示:

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

    【讨论】:

      猜你喜欢
      • 2011-05-18
      • 1970-01-01
      • 1970-01-01
      • 2019-02-23
      • 2010-10-29
      • 1970-01-01
      • 2017-05-14
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多