Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Node.js read and execute a Ruby file?

Is there a npm that can install and or use a ruby file as is and execute inside of node.js? I'm curious because I want want to run two different ruby scripts at the same time.

like image 874
marriedjane875 Avatar asked Apr 14 '15 10:04

marriedjane875


People also ask

How do I run a Ruby script from the shell?

Now, to run the program, simply enter the command ./test. Whether you invoke the Ruby interpreter manually with the Ruby command or run the Ruby script directly is up to you.


1 Answers

Really simple by using child_process#exec

var exec = require('child_process').exec

exec('./script.rb', function (error, stdout, stderr) {
  console.log('stdout: ' + stdout);
  console.log('stderr: ' + stderr);
  console.log('error: ' + error);
});

Docs here: child_process.exec

like image 98
Talgat Medetbekov Avatar answered Oct 17 '22 09:10

Talgat Medetbekov