0

我用这行代码send_csr1从方法中调用方法:send_crs

send_csr1(pipe.read,@username,@password)  

问题是通常会执行下一行代码:

pipe.close_write

但不知何故,它不会导致 cmd 永远不会关闭。当我手动关闭它时,我收到错误:

  in `read': Interrupt
    from stack.rb:49:in `block in send_csr'
    from stack.rb:45:in `popen'
    from stack.rb:45:in `send_csr'
    from stack.rb:88:in `block in <main>'
    from stack.rb:87:in `each'
    from stack.rb:87:in `<main>'

我的问题是我必须在我的代码中更改什么,ruby surley 关闭了 cmd?

我的完整代码:

def send_csr
 IO.popen('cmd', 'r+') do |pipe|
 pipe.puts('cd C:/OpenSSL/bin')
 pipe.puts('openssl.exe')
 pipe.puts("req  -config c:/OpenSSL/openssl.cnf -in  #{@csr}")
 send_csr1(pipe.read,@username,@password)   
 pipe.close_write
end
end

def send_csr1(text,user,password)
 @conn.basic_auth(user,password)
 @res = @conn.get do |request|  
 request.url "csr"
 request.headers['Content-Type'] = 'text/plain'
 request.body = "#{text}"
end
end
4

0 回答 0