Search code examples
rubymruby

mruby: How to execute shell commands?


In mruby how can I run shell commands with %x(), `` or system? Is there an mgem I can use for it?


Solution

  • Try mruby-io which implementes popen: https://github.com/iij/mruby-io/blob/728d313b2c238ac0f41a4aa7e4a88e6a8fee8079/mrblib/kernel.rb#L2-L4

    Or type mruby-process which implements system: https://github.com/iij/mruby-process/blob/c31010dc0440335a7693fd70ae005c79bd1378ec/src/process.c#L368