T
Tyler Knappe
I'm attempting to use Ruby to make system calls (in this case python
scripts) which return values, that I then hand off to Ruby on Rails to
populate a webpage. However, I've run into a problem with capturing the
return values of system calls.
Using system () only returns whether the command was executed
successfully.
Using `[system call]` captures stdout, which works, but only if I then
chomp on the string returned. I would then have to make some
assumptions about the size of each value returned (I really see this
being error prone).
Using systemu (http://codeforpeople.com/lib/ruby/systemu/) allows me to
capture stdout, stderror, and status. Not returned values.
One work around is to call multiple python scripts, but this could
become very expensive very fast, because I'm querying a database (plus
one call returns all the values I need).
Ideally, I would be able to return an array of values from my python
script then use them in ruby to populate the webpage. Is this possible?
scripts) which return values, that I then hand off to Ruby on Rails to
populate a webpage. However, I've run into a problem with capturing the
return values of system calls.
Using system () only returns whether the command was executed
successfully.
Using `[system call]` captures stdout, which works, but only if I then
chomp on the string returned. I would then have to make some
assumptions about the size of each value returned (I really see this
being error prone).
Using systemu (http://codeforpeople.com/lib/ruby/systemu/) allows me to
capture stdout, stderror, and status. Not returned values.
One work around is to call multiple python scripts, but this could
become very expensive very fast, because I'm querying a database (plus
one call returns all the values I need).
Ideally, I would be able to return an array of values from my python
script then use them in ruby to populate the webpage. Is this possible?