Forum: Ruby on Rails Call other programs and need return value

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.
lily (Guest)
on 2008-12-18 11:45
(Received via mailing list)
hi, all,
You know if you use system call to call a perl script in Ruby's
controller, it will only return the status for the  status of
execution but not the return value of perl script.
I really need the return value of the perl script, can I get it and
how can I get it?
mikebind (Guest)
on 2008-12-18 20:50
(Received via mailing list)
One possibility would be for your Perl script to write it to a file,
then have your Ruby controller read the file.  I'd like to know if
there are other ways, though...
Robert W. (Guest)
on 2008-12-18 21:01
mikebind wrote:
> One possibility would be for your Perl script to write it to a file,
> then have your Ruby controller read the file.  I'd like to know if
> there are other ways, though...

Well I do know this. Just as in bash scripting using the backquote
(tick) around command runs in a subshell and returns the standard output
from the command.

Example:

irb(main):001:0> `date`
=> "Thu Dec 18 14:00:09 EST 2008\n"
irb(main):002:0>

So as long as your Perl script outputs the result to standard out this
should work.
This topic is locked and can not be replied to.