るりまサーチ

最速Rubyリファレンスマニュアル検索!
55件ヒット [1-55件を表示] (0.135秒)
トップページ > クエリ:i[x] > クエリ:h[x] > クエリ:close[x] > クエリ:popen3[x]

別のキーワード

  1. _builtin to_h
  2. hash to_h
  3. struct to_h
  4. array to_h
  5. enumerable to_h

種類

ライブラリ

モジュール

キーワード

検索結果

Open3.#popen3(*cmd) -> [IO, IO, IO, Thread] (18592.0)

外部プログラム cmd を実行し、そのプロセスの標準入力、標準出力、標準エラー 出力に接続されたパイプと実行したプロセスを待つためのスレッドを 4 要素の 配列で返します。

...パイプと実行したプロセスを待つためのスレッドを 4 要素の
配列で返します。

require 'open3'
stdin, stdout, stderr, wait_thr = *Open3.popen3("/usr/bin/nroff -man")

@param cmd 実行するコマンドを指定します。

@return ブロックを指定した場合...
...にパイプ
close します。この場合はブロックの最後の式の結果を返します。

require 'open3'

Open3.popen3("read stdin; echo stdout; echo stderr >&2") {|stdin, stdout, stderr, wait_thr|
stdin.puts "stdin"
stdin.close # または close_write
p stdout.r...
...p stderr.read
}
#=> "stdout\n"
"stderr\n"


stdin への入力が終わったらできる限り早く close close_write
で閉じるべきです。

[UNIX系OS固有の注意] Open3 で作成した子プロセスは
wait(2) しなくてもゾンビになりません。

引数 cmd...

Open3.#popen3(*cmd) {|stdin, stdout, stderr, wait_thr| ... } -> () (18392.0)

外部プログラム cmd を実行し、そのプロセスの標準入力、標準出力、標準エラー 出力に接続されたパイプと実行したプロセスを待つためのスレッドを 4 要素の 配列で返します。

...パイプと実行したプロセスを待つためのスレッドを 4 要素の
配列で返します。

require 'open3'
stdin, stdout, stderr, wait_thr = *Open3.popen3("/usr/bin/nroff -man")

@param cmd 実行するコマンドを指定します。

@return ブロックを指定した場合...
...にパイプ
close します。この場合はブロックの最後の式の結果を返します。

require 'open3'

Open3.popen3("read stdin; echo stdout; echo stderr >&2") {|stdin, stdout, stderr, wait_thr|
stdin.puts "stdin"
stdin.close # または close_write
p stdout.r...
...p stderr.read
}
#=> "stdout\n"
"stderr\n"


stdin への入力が終わったらできる限り早く close close_write
で閉じるべきです。

[UNIX系OS固有の注意] Open3 で作成した子プロセスは
wait(2) しなくてもゾンビになりません。

引数 cmd...

Open3.#pipeline_rw(*cmds) -> [IO, IO, [Thread]] (6212.0)

指定したコマンドのリストをパイプで繋いで順番に実行します。最初の コマンドの標準入力に書き込む事も最後のコマンドの標準出力を受けとる事も できます。

...以下のように String か Array で指定します。
commandline にはコマンド全体(例. "nroff -man")を表す
String を指定します。
options には Hash で指定します。
env には環境変数を Hash で指定します。...
...配列で返します。

例:

require "open3"

Open3.pipeline_rw("sort", "cat -n") {|stdin, stdout, wait_thrs|
stdin.puts "foo"
stdin.puts "bar"
stdin.puts "baz"

# sortコマンドにEOFを送る。
stdin.close

# stdinに渡した文字列をsortコマンド...
...が並べ替えたものに、catコマンド
# が行番号を付けた文字列が表示される。
p stdout.read #=> " 1\tbar\n 2\tbaz\n 3\tfoo\n"
}

@see Open3.#popen3...

Open3.#pipeline_rw(*cmds) {|first_stdin, last_stdout, wait_thrs| ... } -> () (6212.0)

指定したコマンドのリストをパイプで繋いで順番に実行します。最初の コマンドの標準入力に書き込む事も最後のコマンドの標準出力を受けとる事も できます。

...以下のように String か Array で指定します。
commandline にはコマンド全体(例. "nroff -man")を表す
String を指定します。
options には Hash で指定します。
env には環境変数を Hash で指定します。...
...配列で返します。

例:

require "open3"

Open3.pipeline_rw("sort", "cat -n") {|stdin, stdout, wait_thrs|
stdin.puts "foo"
stdin.puts "bar"
stdin.puts "baz"

# sortコマンドにEOFを送る。
stdin.close

# stdinに渡した文字列をsortコマンド...
...が並べ替えたものに、catコマンド
# が行番号を付けた文字列が表示される。
p stdout.read #=> " 1\tbar\n 2\tbaz\n 3\tfoo\n"
}

@see Open3.#popen3...

ruby 1.6 feature (1140.0)

ruby 1.6 feature ruby version 1.6 は安定版です。この版での変更はバグ修正がメイン になります。

...by version 1.6 は安定版です。この版での変更はバグ修正がメイン
になります。

((<stable-snapshot|URL:ftp://ftp.netlab.co.jp/pub/lang/ruby/stable-snapshot.tar.gz>)) は、日々更新される安定版の最新ソースです。

== 1.6.8 (2002-12-24) -> stable-snapshot

:...
...# -v が無効 (ruby 1.6.7 (2002-03-01) [i586-linux])

=> ruby: No program input from stdin allowed in tainted mode (SecurityError)

=> ruby 1.6.7 (2002-07-30) [i586-linux]

: 2002-05-20 IO#close

双方向のパイプの dup を close_write するとエラーになっていまし...
...3 (2001-03-19) [i586-linux]
[[1], [2], [3]]

# => ruby 1.6.4 (2001-06-04) [i586-linux]
[1, 2, 3]

: $SAFE / alias

$SAFE = 4 のときグローバル変数のエイリアスを許さないようにしました。
((<ruby-dev:13287>))

: ((<open3/Open3.popen3>))

終了し...

絞り込み条件を変える