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.
0d5f18e7352dede4939474b371f2241f?d=identicon&s=25 lily (Guest)
on 2008-12-18 10: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?
Fdb5fc6183ee5e6651dc2ee3cdfdd016?d=identicon&s=25 mikebind (Guest)
on 2008-12-18 19: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...
280b78a61a968391b7e07e912be102a8?d=identicon&s=25 Robert Walker (robert4723)
on 2008-12-18 20: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.