3

I'm calling a C executable in my Rails(-v 2.3.5) application using the system() call.

makefile_path = File.expand_path('./c_executalbe', Rails.root)
system(makefile_path)

Everything works fine on my local machine but for some reason that system() call won't run on the server(dreamhost). And there is no error message in log/production.log. I would like to see the returned output of that system call in the log. How can I do that?

Thanks in advance!

1 Answer 1

6

See: http://ruby-doc.org/core/classes/Kernel.html#M005960

Usage:

output = %x(command)
output = `command`
output = Kernel.send(:`, "command")

You'll get the command output.

If command comes from a variable, as in your case, you can interpolate:

output = %x(#{makefile_path})
output = `#{makefile_path}`
output = Kernel.send(:`, makefile_path)

To log it into log/production.log:

logger.info output
# or
puts output
Sign up to request clarification or add additional context in comments.

1 Comment

I am unable to log it on production using Logger.info(cmd_output). I am using thin server.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.