Forum: Ruby on Rails Capturing system console information

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
640f3ccd1c6308ccdf46950d0d4ae140?d=identicon&s=25 Ryan Mckenzie (mckenzie)
on 2009-01-09 17:12
Hello,

I have a simple web application that executes a .exe program through my
controller.  The exe program processes some information and displays an
output on the script/server output.  Is it possible to catch this
information from the console and output it back to the user?

I have tried the following but it does not seem to work:

puts << system.readlines(separator=$/)

Regards,
McKenzie.
8fa0f5c2bf8ad238baa4e20cb0360ebd?d=identicon&s=25 Matt Harrison (iwasinnamuknow)
on 2009-01-09 17:21
(Received via mailing list)
Ryan Mckenzie wrote:
>
> Regards,
> McKenzie.

Perhaps the backtick method would work better? I found that system()
calls sometimes returned random data at the end of the result.

output = `/path/to/app/to/execute`
puts output

worked a lot better for my case.

HTH

Matt
640f3ccd1c6308ccdf46950d0d4ae140?d=identicon&s=25 Ryan Mckenzie (mckenzie)
on 2009-01-09 17:30
Matt Harrison wrote:
> Ryan Mckenzie wrote:
>>
>> Regards,
>> McKenzie.
>
> Perhaps the backtick method would work better? I found that system()
> calls sometimes returned random data at the end of the result.
>
> output = `/path/to/app/to/execute`
> puts output
>
> worked a lot better for my case.
>
> HTH
>
> Matt

Hi Matt,

I also need to input some parameters with the program to but I dont
think the backtick method supports that?  This is what I have so far...

if system("\"E:\\rails\\public\\progs\\web.exe\"
\"E:\\rails\\public\\progs\\temp.txt\" set=\"10\"")
      flash[:notice]= "Console output here"
end

Thanks
This topic is locked and can not be replied to.