D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
proc
/
self
/
root
/
opt
/
alt
/
ruby34
/
share
/
ri
/
system
/
Open3
/
Filename :
capture2e-i.ri
back
Copy
U:RDoc::AnyMethod[iI"capture2e:ETI"Open3#capture2e;TF:privateo:RDoc::Markup::Document:@parts[/o:RDoc::Markup::Paragraph; [I"/Basically a wrapper for Open3.popen3 that:;To:RDoc::Markup::BlankLine o:RDoc::Markup::List: @type:BULLET:@items[o:RDoc::Markup::ListItem:@label0; [o; ; [I"OCreates a child process, by calling Open3.popen3 with the given arguments ;TI"?(except for certain entries in hash +options+; see below).;To;;0; [o; ; [I"HReturns as string +stdout_and_stderr_s+ the merged standard output ;TI"-and standard error of the child process.;To;;0; [o; ; [I";Returns as +status+ a <tt>Process::Status</tt> object ;TI":that represents the exit status of the child process.;T@o; ; [I">Returns the array <tt>[stdout_and_stderr_s, status]</tt>:;T@o:RDoc::Markup::Verbatim; [I"Astdout_and_stderr_s, status = Open3.capture2e('echo "Foo"') ;TI"<# => ["Foo\n", #<Process::Status: pid 2371692 exit 0>] ;T:@format0o; ; [I"LLike Process.spawn, this method has potential security vulnerabilities ;TI"%if called with untrusted input; ;TI"Psee {Command Injection}[rdoc-ref:command_injection.rdoc@Command+Injection].;T@o; ; [I"KUnlike Process.spawn, this method waits for the child process to exit ;TI"4before returning, so the caller need not do so.;T@o; ; [I"HIf the first argument is a hash, it becomes leading argument +env+ ;TI""in the call to Open3.popen3; ;TI"Isee {Execution Environment}[rdoc-ref:Process@Execution+Environment].;T@o; ; [I"LIf the last argument is a hash, it becomes trailing argument +options+ ;TI""in the call to Open3.popen3; ;TI"Asee {Execution Options}[rdoc-ref:Process@Execution+Options].;T@o; ; [I""The hash +options+ is given; ;TI"=two options have local effect in method Open3.capture2e:;T@o;; ;;[o;;0; [o; ; [I"IIf entry <tt>options[:stdin_data]</tt> exists, the entry is removed ;TI"Band its string value is sent to the command's standard input:;T@o;; [I"/Open3.capture2e('tee', stdin_data: 'Foo') ;TI":# => ["Foo", #<Process::Status: pid 2371732 exit 0>] ;T;0o;;0; [o; ; [I"JIf entry <tt>options[:binmode]</tt> exists, the entry is removed and ;TI"1the internal streams are set to binary mode.;T@o; ; [I":The single required argument is one of the following:;T@o;; ;;[o;;0; [o; ; [I"'+command_line+ if it is a string, ;TI"Fand if it begins with a shell reserved word or special built-in, ;TI"2or if it contains one or more metacharacters.;To;;0; [o; ; [I"+exe_path+ otherwise.;T@o; ; [I"#<b>Argument +command_line+</b>;T@o; ; [I"P\String argument +command_line+ is a command line to be passed to a shell; ;TI"Nit must begin with a shell reserved word, begin with a special built-in, ;TI" or contain meta characters:;T@o;; [I"LOpen3.capture2e('if true; then echo "Foo"; fi') # Shell reserved word. ;TI"<# => ["Foo\n", #<Process::Status: pid 2371740 exit 0>] ;TI"AOpen3.capture2e('echo') # Built-in. ;TI"9# => ["\n", #<Process::Status: pid 2371774 exit 0>] ;TI"POpen3.capture2e('date > date.tmp') # Contains meta character. ;TI"7# => ["", #<Process::Status: pid 2371812 exit 0>] ;T;0o; ; [I"MThe command line may also contain arguments and options for the command:;T@o;; [I"#Open3.capture2e('echo "Foo"') ;TI"<# => ["Foo\n", #<Process::Status: pid 2326183 exit 0>] ;T;0o; ; [I"<b>Argument +exe_path+</b>;T@o; ; [I"1Argument +exe_path+ is one of the following:;T@o;; ;;[o;;0; [o; ; [I"3The string path to an executable to be called.;To;;0; [o; ; [I"<A 2-element array containing the path to an executable ;TI"Dand the string to be used as the name of the executing process.;T@o; ; [I" Example:;T@o;; [I"&Open3.capture2e('/usr/bin/date') ;TI"X# => ["Sat Sep 30 09:01:46 AM CDT 2023\n", #<Process::Status: pid 2371820 exit 0>] ;T;0o; ; [I"PRuby invokes the executable directly, with no shell and no shell expansion:;T@o;; [I"<Open3.capture2e('doesnt_exist') # Raises Errno::ENOENT ;T;0o; ; [I"CIf one or more +args+ is given, each is an argument or option ;TI"$to be passed to the executable:;T@o;; [ I"$Open3.capture2e('echo', 'C #') ;TI"<# => ["C #\n", #<Process::Status: pid 2371856 exit 0>] ;TI"/Open3.capture2e('echo', 'hello', 'world') ;TI"C# => ["hello world\n", #<Process::Status: pid 2371894 exit 0>];T;0: @fileI"lib/open3.rb;T:0@omit_headings_from_table_of_contents_below0I"�Open3.capture2e([env, ] command_line, options = {}) -> [stdout_and_stderr_s, status] Open3.capture2e([env, ] exe_path, *args, options = {}) -> [stdout_and_stderr_s, status] ;T0[ I"(*cmd);T@�FI" Open3;TcRDoc::NormalModule00