diff options
| author | mo khan <mo@mokhan.ca> | 2013-08-28 07:20:13 -0600 |
|---|---|---|
| committer | mo khan <mo@mokhan.ca> | 2013-08-28 07:20:13 -0600 |
| commit | db1191ec0e7305d684383f8974e2fa437f77ad5a (patch) | |
| tree | 5e27b197dff849d22d8e1f50eb75aa499b16bd06 /code/snippets/spawn_popen_block.rb | |
Diffstat (limited to 'code/snippets/spawn_popen_block.rb')
| -rw-r--r-- | code/snippets/spawn_popen_block.rb | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/code/snippets/spawn_popen_block.rb b/code/snippets/spawn_popen_block.rb new file mode 100644 index 0000000..193af6a --- /dev/null +++ b/code/snippets/spawn_popen_block.rb @@ -0,0 +1,8 @@ +# An IO object is passed into the block. In this case we open the stream +# for writing, so the stream is set to the STDIN of the spawned process. +# +# If we open the stream for reading (the default) then +# the stream is set to the STDOUT of the spawned process. +IO.popen('less', 'w') { |stream| + stream.puts "some\ndata" +} |
