Problems With IO.popen

Howdy.

I am trying to launch an external shell process from my Rails app using
IO.popen.

The process runs just fine when I am logged in as the user from the
shell
but when I run it from Rails, the task doesn’t run properly and the
output
is too truncated to see any errors.

Anything special I need to worry about when running shell tasks this
way?

I have code like the following:

logger.debug(“Command String: #{command_string}”)
pipe = IO.popen(command_string, “w+”)
if pipe
@tmailer_out = pipe.readlines
end
logger.debug(“Mailer Out: #{@tmailer_out}”)

So, running ‘command_string’ in the shell as the user ‘mongrel’, it
works
fine. But the above only produces about 3 characters of output.

Any help is appreciated.

Hunter

pipe = IO.popen(command_string, “w+”)

So, running ‘command_string’ in the shell as the user ‘mongrel’, it works
fine. But the above only produces about 3 characters of output.

using popen() in the core of your app is a bad idea… you only have a
few rails instances to work with. some cases as few as one… when this
is blocked, nobodies requests get through. secondly it causes all sorts
of weird problems. if want to use it in an app i’d try it via
backgroundrb. make sure the env is right (eg PATH, character encodings,
etc). but even with a proper env, ive had popen() in ruby act really
weird, especially on windows…