Executing Ruby script from PHP and getting output

前端 未结 2 873
鱼传尺愫
鱼传尺愫 2021-01-15 04:51

I have this Ruby script (test.rb):

print \"hello\"

And I have this PHP script (test.php):

$cmd = \"ruby test.rb\";
system($         


        
相关标签:
2条回答
  • 2021-01-15 05:23

    system would capture the output of the ruby script.

    you might want to do:

    $cmd = "ruby test.rb";
    echo system($cmd);
    
    0 讨论(0)
  • 2021-01-15 05:27

    Its working for me, check whether both ruby script and php in the same folder and installed ruby in your machine

    <?php
    $cmd = "ruby test.rb";     
    system($cmd);
    ?>
    
    0 讨论(0)
提交回复
热议问题