如何将HTML表单输入通过管道输入到PHP然后到Ruby


How do I pipe HTML form input into PHP and then to Ruby?

这可能看起来很愚蠢。如果无法实现,请告诉我。
所以:我有一个Rasperry Pi(RPi),它运行Raspbian和nginx,用于简单的家庭网络文件共享服务器。我这样做主要是为了学习,并直接潜入其中。无论如何,我的登录系统如下:

登录.html:

<html>
...
<form action="cgi-bin/loginHandler.php">
    <label for="username">Username:</label>
    <input name="username">
    <br/>
    <label for="username">Password:</label>
    <input name="password">
    <input name="button" type="submit" value="Submit">
</form>
...
</html>

cgi-bin/loginHandler.php:

<?php
exec("./login.rb $arg1 $arg2")
?>

cgi-bin/login.rb:

#!/usr/bin/ruby1.9.1
#update-alternatives changed "ruby" to "ruby1.9.1"
cmdArray = Array.new
ARGV.each do |a|
    cmdArray.push a
end
#backwards because I used push
if cmdArray[1] == "/u/afdsadf" and cmdArray[0] == "/r/unixporn"
    htmlFile = File.new("loggedIn.html", "w+")
    htmlFile.puts("<html><head></head><body>You are now logged in!</body></html>")
else
    htmlFile = File.new("notLoggedIn.html", "w+")
    htmlFile.puts("<html><head></head><body>You are now logged in!</body></html>")
end

我检查了我的cgi-bin目录,其中肯定没有"loggedIn.html"或"notLoggedIn.html",所以Ruby要么抛出错误,要么根本没有运行。再说一次,使用PHP可能首先是一个坏主意。我也可能需要表单本身的method,但我不知道该使用什么。

尝试改用绝对路径:

exec("/path/to/login.rb $arg1 $arg2")

或者明确称红宝石:

exec("/usr/bin/ruby /path/to/login.rb $arg1 $arg2")

与您尝试打开的文件相同:

htmlFile = File.new("/path/to/loggedIn.html", "w+")
htmlFile = File.new("/path/to/notLoggedIn.html", "w+")