Ruby的標準popen3模塊在Windows上不起作用。是否有一個保留的替代品可以分離stdin,stdout和stderr?什麼是在Windows中讀寫子進程的等價物?
1
A
回答
5
POpen4 gem在unix和Windows之間有一個共同的接口。下面的例子(來自他們的網站)就像一個魅力。
require 'rubygems'
require 'popen4'
status =
POpen4::popen4("cmd") do |stdout, stderr, stdin, pid|
stdin.puts "echo hello world!"
stdin.puts "echo ERROR! 1>&2"
stdin.puts "exit"
stdin.close
puts "pid : #{ pid }"
puts "stdout : #{ stdout.read.strip }"
puts "stderr : #{ stderr.read.strip }"
end
puts "status : #{ status.inspect }"
puts "exitstatus : #{ status.exitstatus }"
1
popen3與windows 1.9.x上的MRI 1.9.x一起使用。見http://en.wikibooks.org/wiki/Ruby_Programming/Running_Multiple_Processes
相關問題
- 1. 什麼是Windows CE的kbhit等價物?
- 2. 什麼是Application.StartupPath的Windows CE等價物?
- 3. 什麼是Windows上的非緩衝程序的等價物?
- 4. 在java中重寫「equals」的clojure等價物是什麼?
- 5. 什麼是VC7中的strtok_s等價物?
- 6. 什麼是Silverlight中的OnRender等價物?
- 7. C#中TreeBidiMap的等價物是什麼?
- 8. 什麼是C#中的vbNullChar等價物?
- 9. MySQL中'go'的等價物是什麼?
- 10. Bash中%%〜nxD的等價物是什麼?
- 11. C#中memset的等價物是什麼?
- 12. Monotouch中的CGPDFDocumentGetCatalog等價物是什麼?
- 13. C#中bigint的等價物是什麼?
- 14. 什麼是android中的dataWithContentsOfURL等價物?
- 15. jquery中Ajax.updater的等價物是什麼?
- 16. url中的「 - 」等價物是什麼?
- 17. TensorFlow中np.std()的等價物是什麼?
- 18. 什麼是Ruby中的「sys.stdout.write()」等價物?
- 19. wxWidgets中UpdateWindow()的等價物是什麼?
- 20. JQuery中innerHTML的等價物是什麼?
- 21. Bindingsource中EOF的等價物是什麼?
- 22. RDFlib中rdf:ID的等價物是什麼?
- 23. python中'gem'的等價物是什麼?
- 24. gcc中的#pragma等價物是什麼?
- 25. Python中imadjust的等價物是什麼?
- 26. python中print_r()的等價物是什麼?
- 27. 什麼是node.js中process.on('SIGINT')的Windows等價物?
- 28. 什麼是Windows中_strnicmp的LPTSTR等價物?
- 29. 什麼是Windows系統中的/ dev/shm等價物?
- 30. 在Windows中是否有XEmbed等價物?