change system to popen

This commit is contained in:
nigel007 2019-07-22 14:04:12 +08:00
parent deb42a19d0
commit 154aecfa14
1 changed files with 11 additions and 2 deletions

View File

@ -17,6 +17,7 @@ class PullRequestsController < ApplicationController
require 'json'
require 'open-uri'
require 'uri'
require 'string.io' # add by zxh: 将控制台shell命令输出到指定位置
# 返回json格式
def index
@ -335,8 +336,16 @@ class PullRequestsController < ApplicationController
pushTXInfoJson = pushTXInfo.to_json
# 发送交易
Rails.logger.info("before executing chain_trustie command...")
result = system "chain_trustie pushPRTX " + pushTXInfoJson
Rails.logger.info(result)
cmd = "chain_trustie pushPRTX " + pushTXInfoJson
# result = system # 执行失败了
output = StringIO.new
IO.popen(cmd) do |pipe|
pipe.each do |line|
Rails.logger.info(line)
end
end
Rails.logger.info(output.string)
# Rails.logger.info(result)
Rails.logger.info("after executing chain_trustie command...")
# add by zxh end