# Call other programs and need return value

**URL:** <https://www.ruby-forum.com/t/call-other-programs-and-need-return-value/155937>\
**Category:** Rails\
**Created:** [December 18, 2008, 10:45am UTC](https://www.ruby-forum.com/t/call-other-programs-and-need-return-value/155937 "2008-12-18T10:45:32Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![lily](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/97f17d/32.png) [@lily](https://www.ruby-forum.com/u/lily)\
**Post date:** [December 18, 2008, 10:45am UTC](https://www.ruby-forum.com/t/call-other-programs-and-need-return-value/155937/1 "2008-12-18T10:45:32Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![lily](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/97f17d/32.png) [@lily](https://www.ruby-forum.com/u/lily)\
**Post date:** [December 18, 2008, 7:50pm UTC](https://www.ruby-forum.com/t/call-other-programs-and-need-return-value/155937/2 "2008-12-18T19:50:04Z")

</div>

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…

---

<div class="post-metadata">

**Author:** ![lily](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/97f17d/32.png) [@lily](https://www.ruby-forum.com/u/lily)\
**Post date:** [December 18, 2008, 8:01pm UTC](https://www.ruby-forum.com/t/call-other-programs-and-need-return-value/155937/3 "2008-12-18T20:01:05Z")

</div>

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.
