ÿØÿà JFIF    ÿÛ „  ( %!1!%)+//.383,7(-.+  -%%-////---/-.+/--+------/------/--0+--/-/-----.-----ÿÀ  ¥2" ÿÄ     ÿÄ J    ! 1AQ"aq2‘#BR‚¡ÁÑ3br’¢±Âð$CSƒ²á4c“%DsÓñÿÄ   ÿÄ *  !1AQa‘"2q3±ð#b¡ÿÚ   ? ¼QxJQaÍuò¸Zö Úü8,ÐÚú "SSn<rçù–´âE—^ªBÖ9À\†¸ÔÁT­ÃÛ5 ëd´³Í#Ý;Þ38œî ¶H£M:wÎ3…³…âpÔF&‚FK¸9„â4àGEõªfÿ ‘ñ(ßw­pŽF|È¥ù®häðÍѶ¹‘[ÒinÙW¶ùñY˜Q{›K"išÒ[Ú8žë\F¹@-?v"ÔU”,ìöžkÿ {I‡£šÍ?e ríV ?> ......................................... ............................................................................. ÿØÿà JFIF    ÿÛ „  ( %!1!%)+//.383,7(-.+  -%%-////---/-.+/--+------/------/--0+--/-/-----.-----ÿÀ  ¥2" ÿÄ     ÿÄ J    ! 1AQ"aq2‘#BR‚¡ÁÑ3br’¢±Âð$CSƒ²á4c“%DsÓñÿÄ   ÿÄ *  !1AQa‘"2q3±ð#b¡ÿÚ   ? ¼QxJQaÍuò¸Zö Úü8,ÐÚú "SSn<rçù–´âE—^ªBÖ9À\†¸ÔÁT­ÃÛ5 ëd´³Í#Ý;Þ38œî ¶H£M:wÎ3…³…âpÔF&‚FK¸9„â4àGEõªfÿ ‘ñ(ßw­pŽF|È¥ù®häðÍѶ¹‘[ÒinÙW¶ùñY˜Q{›K"išÒ[Ú8žë\F¹@-?v"ÔU”,ìöžkÿ {I‡£šÍ?e ríV ?> ......................................... ............................................................................. ???????????????????????????????????? ???????????????????????????????????? ÿØÿà JFIF    ÿÛ „  ( %!1!%)+//.383,7(-.+  -%%-////---/-.+/--+------/------/--0+--/-/-----.-----ÿÀ  ¥2" ÿÄ     ÿÄ J    ! 1AQ"aq2‘#BR‚¡ÁÑ3br’¢±Âð$CSƒ²á4c“%DsÓñÿÄ   ÿÄ *  !1AQa‘"2q3±ð#b¡ÿÚ   ? ¼QxJQaÍuò¸Zö Úü8,ÐÚú "SSn<rçù–´âE—^ªBÖ9À\†¸ÔÁT­ÃÛ5 ëd´³Í#Ý;Þ38œî ¶H£M:wÎ3…³…âpÔF&‚FK¸9„â4àGEõªfÿ ‘ñ(ßw­pŽF|È¥ù®häðÍѶ¹‘[ÒinÙW¶ùñY˜Q{›K"išÒ[Ú8žë\F¹@-?v"ÔU”,ìöžkÿ {I‡£šÍ?e ríV ?> ......................................... ............................................................................. ÿØÿà JFIF    ÿÛ „  ( %!1!%)+//.383,7(-.+  -%%-////---/-.+/--+------/------/--0+--/-/-----.-----ÿÀ  ¥2" ÿÄ     ÿÄ J    ! 1AQ"aq2‘#BR‚¡ÁÑ3br’¢±Âð$CSƒ²á4c“%DsÓñÿÄ   ÿÄ *  !1AQa‘"2q3±ð#b¡ÿÚ   ? ¼QxJQaÍuò¸Zö Úü8,ÐÚú "SSn<rçù–´âE—^ªBÖ9À\†¸ÔÁT­ÃÛ5 ëd´³Í#Ý;Þ38œî ¶H£M:wÎ3…³…âpÔF&‚FK¸9„â4àGEõªfÿ ‘ñ(ßw­pŽF|È¥ù®häðÍѶ¹‘[ÒinÙW¶ùñY˜Q{›K"išÒ[Ú8žë\F¹@-?v"ÔU”,ìöžkÿ {I‡£šÍ?e ríV ?> ......................................... ............................................................................. ???????????????????????????????????? ???????????????????????????????????? U:RDoc::AnyMethod[iI" popen:ETI"IO::popen;TT: publico:RDoc::Markup::Document: @parts[Ho:RDoc::Markup::Paragraph; [I"6Executes the given command +cmd+ as a subprocess ;TI"Awhose $stdin and $stdout are connected to a new stream +io+.;To:RDoc::Markup::BlankLineo; ; [I"XThis method has potential security vulnerabilities if called with untrusted input; ;TI">see {Command Injection}[rdoc-ref:command_injection.rdoc].;T@o; ; [I"3If no block is given, returns the new stream, ;TI"Pwhich depending on given +mode+ may be open for reading, writing, or both. ;TI"QThe stream should be explicitly closed (eventually) to avoid resource leaks.;T@o; ; [ I"$? and returned.;T@o; ; [I"9Optional argument +mode+ may be any valid \IO mode. ;TI"4See {Access Modes}[rdoc-ref:File@Access+Modes].;T@o; ; [I"FRequired argument +cmd+ determines which of the following occurs:;T@o:RDoc::Markup::List: @type: BULLET: @items[ o:RDoc::Markup::ListItem: @label0; [o; ; [I"The process forks.;To;;0; [o; ; [I")A specified program runs in a shell.;To;;0; [o; ; [I"7A specified program runs with specified arguments.;To;;0; [o; ; [I"OA specified program runs with specified arguments and a specified +argv0+.;T@o; ; [I"%Each of these is detailed below.;T@o; ; [I"VThe optional hash argument +env+ specifies name/value pairs that are to be added ;TI"5to the environment variables for the subprocess:;T@o:RDoc::Markup::Verbatim; [ I"8IO.popen({'FOO' => 'bar'}, 'ruby', 'r+') do |pipe| ;TI"# pipe.puts 'puts ENV["FOO"]' ;TI" pipe.close_write ;TI" pipe.gets ;TI"end => "bar\n" ;T: @format0o; ; [I"/Optional keyword arguments +opts+ specify:;T@o; ; ;;[o;;0; [o; ; [I".{Open options}[rdoc-ref:IO@Open+Options].;To;;0; [o; ; [I"B{Encoding options}[rdoc-ref:encodings.rdoc@Encoding+Options].;To;;0; [o; ; [I"Options for Kernel#spawn.;T@o; ; [I"Forked \Process;T@o; ; [I"\When argument +cmd+ is the 1-character string '-', causes the process to fork:;To;; [ I"IO.popen('-') do |pipe| ;TI" if pipe ;TI"> $stderr.puts "In parent, child pid is #{pipe.pid}\n" ;TI" else ;TI"1 $stderr.puts "In child, pid is #{$$}\n" ;TI" end ;TI" end ;T;0o; ; [I" Output:;T@o;; [I"#In parent, child pid is 26253 ;TI"In child, pid is 26253 ;T;0o; ; [I"6Note that this is not supported on all platforms.;T@o; ; [I"Shell Subprocess;T@o; ; [I"DWhen argument +cmd+ is a single string (but not '-'), ;TI"7the program named +cmd+ is run as a shell command:;T@o;; [I"!IO.popen('uname') do |pipe| ;TI" pipe.readlines ;TI" end ;T;0o; ; [I" Output:;T@o;; [I"["Linux\n"] ;T;0o; ; [I"Another example:;T@o;; [ I")IO.popen('/bin/sh', 'r+') do |pipe| ;TI" pipe.puts('ls') ;TI" pipe.close_write ;TI"( $stderr.puts pipe.readlines.size ;TI" end ;T;0o; ; [I" Output:;T@o;; [I" 213 ;T;0o; ; [I"Program Subprocess;T@o; ; [I"1When argument +cmd+ is an array of strings, ;TI"Zthe program named cmd[0] is run with all elements of +cmd+ as its arguments:;T@o;; [I"+IO.popen(['du', '..', '.']) do |pipe| ;TI"( $stderr.puts pipe.readlines.size ;TI" end ;T;0o; ; [I" Output:;T@o;; [I" 1111 ;T;0o; ; [I"2Program Subprocess with argv0;T@o; ; [I"UWhen argument +cmd+ is an array whose first element is a 2-element string array ;TI"7and whose remaining elements (if any) are strings:;T@o; ; ;;[o;;0; [o; ; [I"dcmd[0][0] (the first string in the nested array) is the name of a program that is run.;To;;0; [o; ; [I"icmd[0][1] (the second string in the nested array) is set as the program's argv[0].;To;;0; [o; ; [I"Vcmd[1..-1] (the strings in the outer array) are the program's arguments.;T@o; ; [I")Example (sets $0 to 'foo'):;T@o;; [I"GIO.popen([['/bin/sh', 'foo'], '-c', 'echo $0']).read # => "foo\n" ;T;0o; ; [I"!Some Special Examples;T@o;; [I"# Set IO encoding. ;TI"IIO.popen("nkf -e filename", :external_encoding=>"EUC-JP") {|nkf_io| ;TI"# euc_jp_string = nkf_io.read ;TI"} ;TI" ;TI"]# Merge standard output and standard error using Kernel#spawn option. See Kernel#spawn. ;TI"9IO.popen(["ls", "/", :err=>[:child, :out]]) do |io| ;TI"& ls_result_with_error = io.read ;TI" end ;TI" ;TI"4# Use mixture of spawn options and IO options. ;TI"9IO.popen(["ls", "/"], :err=>[:child, :out]) do |io| ;TI"& ls_result_with_error = io.read ;TI" end ;TI" ;TI" f = IO.popen("uname") ;TI" p f.readlines ;TI" f.close ;TI"& puts "Parent is #{Process.pid}" ;TI"* IO.popen("date") {|f| puts f.gets } ;TI"S IO.popen("-") {|f| $stderr.puts "#{Process.pid} is here, f is #{f.inspect}"} ;TI" p $? ;TI"? IO.popen(%w"sed -e s|^|| -e s&$&;zot;&", "r+") {|f| ;TI"1 f.puts "bar"; f.close_write; puts f.gets ;TI" } ;T;0o; ; [I" Output (from last section):;T@o;; [ I"["Linux\n"] ;TI"Parent is 21346 ;TI""Thu Jan 15 22:41:19 JST 2009 ;TI"$21346 is here, f is # ;TI"21352 is here, f is nil ;TI"*# ;TI"bar;zot; ;T;0o; ; [I";Raises exceptions that IO.pipe and Kernel.spawn raise.;T: @fileI" io.c;T:0@omit_headings_from_table_of_contents_below0I"yIO.popen(env = {}, cmd, mode = 'r', **opts) -> io IO.popen(env = {}, cmd, mode = 'r', **opts) {|io| ... } -> object ;T0[I" (*args);T@FI"IO;TcRDoc::NormalClass00