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

后端 未结 7 1436

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(<your command here>)
    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.

    0 讨论(0)
提交回复
热议问题