Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
从php运行ruby脚本_Php_Ruby - Fatal编程技术网

从php运行ruby脚本

从php运行ruby脚本,php,ruby,Php,Ruby,Ruby安装在以下位置: .rvm/rubies/ruby-2.2.1/bin Ruby脚本: puts "Hello world" Php脚本: <?php $cmd = "ruby /home/balint/rubytest.rb"; echo system($cmd); ?> 这意味着作为从浏览器运行php脚本的用户,我无法访问服务器上的该目录 有什么想法吗 exec(rubyfile.rb); 只要添加这段代码,它就会执行您的ruby文件。这

Ruby安装在以下位置:

.rvm/rubies/ruby-2.2.1/bin
Ruby脚本:

puts "Hello world"
Php脚本:

<?php
    $cmd = "ruby /home/balint/rubytest.rb";     
    echo system($cmd);
?>
这意味着作为从浏览器运行php脚本的用户,我无法访问服务器上的该目录

有什么想法吗

exec(rubyfile.rb);

只要添加这段代码,它就会执行您的ruby文件。

这可能是一个发送和接收数据的极好教程,这就是我的来源。我试过了,收到
命令返回了一条
消息,所以我决定试试这个简单的脚本。现在我在这里。看起来你不允许以运行PHP脚本的用户的身份读取该文件。没错。它有-rw-rw-r--权限。我所做的是将它复制到public_html文件夹中,在那里我有权运行它。然而,为了现在从php运行ruby脚本,我应该添加我使用的所有gem的绝对路径。解决权限问题或设置所有gem的路径,这里更好的方法是什么?
exec(rubyfile.rb);