Gestionnaire de fichiers - Editer - /opt/cpanel/ea-ruby24/root/usr/share/ri/system/IO/popen-c.ri
Arrière
U:RDoc::AnyMethod[iI" popen:ETI"IO::popen;TT:publico:RDoc::Markup::Document:@parts[o:RDoc::Markup::Paragraph; [I"BRuns the specified command as a subprocess; the subprocess's ;TI"Astandard input and output will be connected to the returned ;TI"<code>IO</code> object.;To:RDoc::Markup::BlankLine o; ; [I"EThe PID of the started process can be obtained by IO#pid method.;T@o; ; [I"._cmd_ is a string or an array as follows.;T@o:RDoc::Markup::Verbatim; [I" cmd: ;TI"7 "-" : fork ;TI"a commandline : command line string which is passed to a shell ;TI"e [env, cmdname, arg1, ..., opts] : command name and zero or more arguments (no shell) ;TI"n [env, [cmdname, argv0], arg1, ..., opts] : command name, argv[0] and zero or more arguments (no shell) ;TI""(env and opts are optional.) ;T:@format0o; ; [I"0If _cmd_ is a +String+ ``<code>-</code>'', ;TI">then a new instance of Ruby is started as the subprocess.;T@o; ; [ I".If <i>cmd</i> is an +Array+ of +String+, ;TI"Hthen it will be used as the subprocess's +argv+ bypassing a shell. ;TI"AThe array can contains a hash at first for environments and ;TI">a hash at last for options similar to <code>spawn</code>.;T@o; ; [I"8The default mode for the new file object is ``r'', ;TI"\but <i>mode</i> may be set to any of the modes listed in the description for class IO. ;TI"8The last argument <i>opt</i> qualifies <i>mode</i>.;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"6# merge standard output and standard error using ;TI"8# spawn option. See the document of Kernel.spawn. ;TI":IO.popen(["ls", "/", :err=>[:child, :out]]) {|ls_io| ;TI") ls_result_with_error = ls_io.read ;TI"} ;TI" ;TI"2# spawn options can be mixed with IO options ;TI":IO.popen(["ls", "/"], :err=>[:child, :out]) {|ls_io| ;TI") ls_result_with_error = ls_io.read ;TI"} ;T; 0o; ; [I"6Raises exceptions which <code>IO.pipe</code> and ;TI"%<code>Kernel.spawn</code> raise.;T@o; ; [I"IIf a block is given, Ruby will run the command as a child connected ;TI"Eto Ruby with a pipe. Ruby's end of the pipe will be passed as a ;TI"parameter to the block. ;TI"IAt the end of block, Ruby closes the pipe and sets <code>$?</code>. ;TI"0In this case <code>IO.popen</code> returns ;TI"the value of the block.;T@o; ; [I"=If a block is given with a _cmd_ of ``<code>-</code>'', ;TI"Jthe block will be run in two separate processes: once in the parent, ;TI"Eand once in a child. The parent process will be passed the pipe ;TI"Hobject as a parameter to the block, the child version of the block ;TI";will be passed +nil+, and the child's standard in and ;TI"Hstandard out will be connected to the parent through the pipe. Not ;TI" available on all platforms.;T@o;; [I"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"RIO.popen("-") {|f| $stderr.puts "#{Process.pid} is here, f is #{f.inspect}"} ;TI" p $? ;TI">IO.popen(%w"sed -e s|^|<foo>| -e s&$&;zot;&", "r+") {|f| ;TI"0 f.puts "bar"; f.close_write; puts f.gets ;TI"} ;T; 0o; ; [I"<em>produces:</em>;T@o;; [I"["Linux\n"] ;TI"Parent is 21346 ;TI""Thu Jan 15 22:41:19 JST 2009 ;TI"$21346 is here, f is #<IO:fd 3> ;TI"21352 is here, f is nil ;TI"*#<Process::Status: pid 21352 exit 0> ;TI"<foo>bar;zot;;T; 0: @fileI" io.c;T:0@omit_headings_from_table_of_contents_below0I"|IO.popen([env,] cmd, mode="r" [, opt]) -> io IO.popen([env,] cmd, mode="r" [, opt]) {|io| block } -> obj ;T0[ I"(*args);T@lFI"IO;TcRDoc::NormalClass00
| ver. 1.4 |
Github
|
.
| PHP 8.0.30 | Génération de la page: 0.01 |
proxy
|
phpinfo
|
Réglages