English 中文(简体)
1. 运行系统在废墟中进行指挥,并与它互动
原标题:Run system command in ruby and interact with it

我需要在指挥线上指挥,要求用户作出反应。 如果它帮助指挥部:

gpg --recipient "Some Name" --encrypt ~/some_file.txt

在你执政时,它警告说,当时有人要求:

如何利用这一关键? (y/N)

回答,让它正确完成。 我一直在努力使用,但我未能确切地说明情况。 这是我尝试的:

Open4::popen4(cmd) do |pid, stdin, stdout, stderr|
  stdin.puts "y"
  stdin.close

  puts "pid        : #{ pid }"
  puts "stdout     : #{ stdout.read.strip }"
  puts "stderr     : #{ stderr.read.strip }"
end

我做了什么错误? 我怎么做呢?

最佳回答
问题回答

gpg 或许会打开终端装置,直接向用户提问——这是一个共同的安全办法,防止将文字完全从档案中翻开。 (关于类似情况,见现成的getpass(3)常规。)

如果你实际上没有足够注意警告读到的话,你也可以使用<代码>gpg。 指挥系统选项--yes:

   --yes  Assume "yes" on most questions.




相关问题
Ruby parser in Java

The project I m doing is written in Java and parsers source code files. (Java src up to now). Now I d like to enable parsing Ruby code as well. Therefore I am looking for a parser in Java that parses ...

rails collection_select vs. select

collection_select and select Rails helpers: Which one should I use? I can t see a difference in both ways. Both helpers take a collection and generates options tags inside a select tag. Is there a ...

RubyCAS-Client question: Rails

I ve installed RubyCAS-Client version 2.1.0 as a plugin within a rails app. It s working, but I d like to remove the ?ticket= in the url. Is this possible?

Ordering a hash to xml: Rails

I m building an xml document from a hash. The xml attributes need to be in order. How can this be accomplished? hash.to_xml

multiple ruby extension modules under one directory

Can sources for discrete ruby extension modules live in the same directory, controlled by the same extconf.rb script? Background: I ve a project with two extension modules, foo.so and bar.so which ...

Text Editor for Ruby-on-Rails

guys which text editor is good for Rubyonrails? i m using Windows and i was using E-Texteditor but its not free n its expired now can anyone plese tell me any free texteditor? n which one is best an ...

热门标签