如何在 Fantom 中捕获进程输出?
How to capture Process output in Fantom?
如何捕获为进程创建的流?请参阅有关流程的有限 Fantom 文档: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)
}
}
您似乎混淆了输入和输出。您想要为进程设置和捕获 output,如下所示:
buf := Buf()
Process() {
command = Str["ipconfig"]
out = buf.out
}.run.join
outStr := buf.flip.readAllStr
echo(outStr)
如何捕获为进程创建的流?请参阅有关流程的有限 Fantom 文档: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)
}
}
您似乎混淆了输入和输出。您想要为进程设置和捕获 output,如下所示:
buf := Buf()
Process() {
command = Str["ipconfig"]
out = buf.out
}.run.join
outStr := buf.flip.readAllStr
echo(outStr)