Running a shell command from Ruby: capturing the output while displaying the output?

后端 未结 7 1443

I have a problem.

I want to run a ruby script from another ruby script and capture it\'s output information while letting it output to the screen too.

runner

7条回答
  •  生来不讨喜
    2021-02-10 03:16

    io = IO.popen()
    log = io.readlines
    io.close
    

    Now in log variable you have the output of executed command. Parse it, convert it, or do whatever you want.

提交回复
热议问题