dongshukou0240 2011-05-18 14:00
浏览 98
已采纳

如何从ruby脚本将$ _POST值传递给php脚本

I need to run a cron job to add a svn repository using reposman.rb for Redmine. But we also have a php script (with an interface) that enable us to create repositories automaticly.

The php script receives a $_POST value, create the repos, sets permissions, assign some group for read and write access to the newly created repos.

My question is this:

  1. how could I execute the php script, instead of the svnadmin create command in reposman.rb?
  2. How can I give a $_POST parameter to the php script, so it could setup my svn repos correctly, using the php script.

Thanks

Edit: Here are some example of what both scripts do.

Ruby script:

...
// Add the repos
system "svnadmin create #{path}"
...

Php script:

// Receive the name of the repos to add
$dir= $_POST["dir"]; 
// Do all the stuff with the permissions
$cmd= "sudo /usr/local/bin/createsvnrepo $dir";
system("$cmd", $retval);
...
  • 写回答

6条回答 默认 最新

  • dongyong1897 2011-06-02 16:14
    关注

    Since, @Richard Knop's comment helped me more than any answer, I will answer my own question to help others.

    I used curb to send a post to the php script.

    reposman.rb

    ...
    # Added at start of file.
    require 'rubygems'
    require 'curb'
    ...
    
    # Replace the creation of repos from 
    module SCM
        module Subversion
            def self.create(path)
                system_or_raise "svnadmin create #{path}"
            end
        end
        ...
    end
    
    # to 
    module SCM
        module Subversion
            def self.create(path)
                Curl::Easy.http_post(
                    "http://example.com/customCreaterepos.php", # Url to the php script
                    Curl::PostField.content('reposName', path)) # Index of php $_POST in script
            end
        end
        ...
    end
    
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(5条)

报告相同问题?

悬赏问题

  • ¥20 java在应用程序里获取不到扬声器设备
  • ¥15 echarts动画效果的问题,请帮我添加一个动画。不要机器人回答。
  • ¥60 许可证msc licensing软件报错显示已有相同版本软件,但是下一步显示无法读取日志目录。
  • ¥15 Attention is all you need 的代码运行
  • ¥15 一个服务器已经有一个系统了如果用usb再装一个系统,原来的系统会被覆盖掉吗
  • ¥15 使用esm_msa1_t12_100M_UR50S蛋白质语言模型进行零样本预测时,终端显示出了sequence handled的进度条,但是并不出结果就自动终止回到命令提示行了是怎么回事:
  • ¥15 前置放大电路与功率放大电路相连放大倍数出现问题
  • ¥80 部署运行web自动化项目
  • ¥15 腾讯云如何建立同一个项目中物模型之间的联系
  • ¥30 VMware 云桌面水印如何添加