Comment obtenir une sortie continue de sous-processus a commencé à utiliser backtick en rubis
-
21-08-2019 - |
Question
J'ai une application Ruby qui exécute fourmi comme un sous-processus en utilisant backtick. Cela fonctionne sans aucun problème. Quand je met ant
, rubis attend le sous-processus, fourmi, pour finir complètement et puis imprime la sortie vers stdout. Comment puis-je obtenir Ruby pour imprimer la sortie du sous-processus continu?
La solution
Vous pouvez utiliser IO.popen
.
IO.popen("ant") do |output|
while line = output.gets do
# ... maybe puts line? something more interesting?
end
end
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow