method
capture3
v1_9_3_125 -
Show latest stable
-
0 notes -
Class: Open3
- 1_8_6_287
- 1_8_7_72
- 1_8_7_330
- 1_9_1_378
- 1_9_2_180 (0)
- 1_9_3_125 (-2)
- 1_9_3_392 (0)
- 2_1_10 (20)
- 2_2_9 (38)
- 2_4_6 (0)
- 2_5_5 (0)
- 2_6_3 (0)
- What's this?
capture3(*cmd, &block)
private
Open3.capture3 captures the standard output and the standard error of a command.
stdout_str, stderr_str, status = Open3.capture3([env,] cmd... [, opts])
The arguments env, cmd and opts are passed to Open3.popen3 except opts[:stdin_data] and opts[:binmode]. See Process.spawn.
If opts[:stdin_data] is specified, it is sent to the command’s standard input.
If opts[:binmode] is true, internal pipes are set to binary mode.
Example:
# dot is a command of graphviz. graph = <<'End' digraph g { a -> b } End layouted_graph, dot_log = Open3.capture3("dot -v", :stdin_data=>graph) o, e, s = Open3.capture3("echo a; sort >&2", :stdin_data=>"foo\nbar\nbaz\n") p o #=> "a\n" p e #=> "bar\nbaz\nfoo\n" p s #=> #<Process::Status: pid 32682 exit 0> # generate a thumnail image using the convert command of ImageMagick. # However, if the image stored really in a file, # system("convert", "-thumbnail", "80", "png:#{filename}", "png:-") is better # because memory consumption. # But if the image is stored in a DB or generated by gnuplot Open3.capture2 example, # Open3.capture3 is considerable. # image = File.read("/usr/share/openclipart/png/animals/mammals/sheep-md-v0.1.png", :binmode=>true) thumnail, err, s = Open3.capture3("convert -thumbnail 80 png:- png:-", :stdin_data=>image, :binmode=>true) if s.success? STDOUT.binmode; print thumnail end