別のキーワード
種類
- モジュール関数 (132)
- インスタンスメソッド (72)
- 特異メソッド (11)
ライブラリ
- ビルトイン (143)
- shell (24)
-
shell
/ command-processor (24) -
shell
/ filter (24)
クラス
- Shell (24)
-
Shell
:: CommandProcessor (24) -
Shell
:: Filter (24)
検索結果
先頭5件
-
Shell
:: CommandProcessor # echo(*strings) -> Shell :: Filter (21119.0) -
実行すると, それらを内容とする Filter オブジェクトを返します.
...ings シェルコマンド echo に与える引数を文字列で指定します。
動作例
require 'shell'
Shell.def_system_command("head")
sh = Shell.new
sh.transact {
glob("*.txt").to_a.each { |file|
file.chomp!
cat(file).each { |l|
echo(l) | tee(file + ".tee")... -
Shell
# echo(*strings) -> Shell :: Filter (18119.0) -
実行すると, それらを内容とする Filter オブジェクトを返します.
...ings シェルコマンド echo に与える引数を文字列で指定します。
動作例
require 'shell'
Shell.def_system_command("head")
sh = Shell.new
sh.transact {
glob("*.txt").to_a.each { |file|
file.chomp!
cat(file).each { |l|
echo(l) | tee(file + ".tee")... -
Shell
:: Filter # echo(*strings) -> Shell :: Filter (18119.0) -
実行すると, それらを内容とする Filter オブジェクトを返します.
...ings シェルコマンド echo に与える引数を文字列で指定します。
動作例
require 'shell'
Shell.def_system_command("head")
sh = Shell.new
sh.transact {
glob("*.txt").to_a.each { |file|
file.chomp!
cat(file).each { |l|
echo(l) | tee(file + ".tee")... -
Shell
:: CommandProcessor # cat(*files) -> Shell :: Filter (3012.0) -
実行すると, それらを内容とする Filter オブジェクトを返します.
...ファイル名を文字列で指定します。
動作例
require 'shell'
Shell.def_system_command("head")
sh = Shell.new
sh.transact {
glob("*.txt").to_a.each { |file|
file.chomp!
cat(file).each { |l|
echo(l) | tee(file + ".tee") >> "all.tee"
}
}
}... -
Shell
:: CommandProcessor # glob(pattern) -> Shell :: Filter (3012.0) -
実行すると, それらを内容とする Filter オブジェクトを返します.
...Dir.[] を参照してください。
動作例
require 'shell'
Shell.def_system_command("head")
sh = Shell.new
sh.transact {
glob("*.txt").to_a.each { |file|
file.chomp!
cat(file).each { |l|
echo(l) | tee(file + ".tee") >> "all.tee"
}
}
}
@see Dir.[]... -
Shell
:: CommandProcessor # tee(file) -> Shell :: Filter (3012.0) -
実行すると, それらを内容とする Filter オブジェクトを返します.
...るファイル名を文字列で指定します。
動作例
require 'shell'
Shell.def_system_command("head")
sh = Shell.new
sh.transact {
glob("*.txt").to_a.each { |file|
file.chomp!
cat(file).each { |l|
echo(l) | tee(file + ".tee") >> "all.tee"
}
}
}... -
Kernel
. # spawn(env , program , *args , options={}) -> Integer (202.0) -
引数を外部コマンドとして実行しますが、生成した 子プロセスの終了を待ち合わせません。生成した子プロセスのプロセスIDを返します。
...数が削除(unsetenv(3))されます。
//emlist[例][ruby]{
# FOO を BAR にして BAZ を削除する
pid = spawn({"FOO"=>"BAR", "BAZ"=>nil}, command)
//}
親プロセスは Process.#waitpid で子プロセスの終了を待ち合わせるか
もしくは Process.#detach で子プロセスを......の環境変数を
クリアします。
//emlist[][ruby]{
# すべての環境変数をクリア
pid = spawn(command, :unsetenv_others=>true)
# FOO だけ
pid = spawn({"FOO"=>"BAR"}, command, :unsetenv_others=>true)
//}
「:pgroup」でプロセスグループを指定できます。
//emlist[][ru......IO.popen で、子プロセスの
stderr と stdout を混ぜる例を以下に示します。
//emlist[][ruby]{
io = IO.popen(["sh", "-c", "echo out; echo err >&2", :err=>[:child, :out]])
p io.read #=> "out\nerr\n
//}
spawn と IO.popen では
デフォルトでは非標準的なファイルデス... -
Kernel
. # spawn(program , *args) -> Integer (202.0) -
引数を外部コマンドとして実行しますが、生成した 子プロセスの終了を待ち合わせません。生成した子プロセスのプロセスIDを返します。
...数が削除(unsetenv(3))されます。
//emlist[例][ruby]{
# FOO を BAR にして BAZ を削除する
pid = spawn({"FOO"=>"BAR", "BAZ"=>nil}, command)
//}
親プロセスは Process.#waitpid で子プロセスの終了を待ち合わせるか
もしくは Process.#detach で子プロセスを......の環境変数を
クリアします。
//emlist[][ruby]{
# すべての環境変数をクリア
pid = spawn(command, :unsetenv_others=>true)
# FOO だけ
pid = spawn({"FOO"=>"BAR"}, command, :unsetenv_others=>true)
//}
「:pgroup」でプロセスグループを指定できます。
//emlist[][ru......IO.popen で、子プロセスの
stderr と stdout を混ぜる例を以下に示します。
//emlist[][ruby]{
io = IO.popen(["sh", "-c", "echo out; echo err >&2", :err=>[:child, :out]])
p io.read #=> "out\nerr\n
//}
spawn と IO.popen では
デフォルトでは非標準的なファイルデス... -
Process
. exec(command , *args) -> () (149.0) -
カレントプロセスを与えられた外部コマンドで置き換えます。
...合、command が shell のメタ文字
//emlist{
* ? {} [] <> () ~ & | \ $ ; ' ` " \n
//}
を含む場合、shell 経由で実行されます。
そうでなければインタプリタから直接実行されます。
引数が複数与えられた場合、第 2 引数以降は command に直接......場合、command はサブシェル経由で実行されます。
そうでない場合、command は exec(2) を使用して実行されるので元の
プログラムからいくつかの環境を引き継ぎます。
@param command 実行する外部コマンド。
@param args command に渡す......引数。
exec "echo *" # echoes list of files in current directory
# never get here
exec "echo", "*" # echoes an asterisk
# never get here... -
Kernel
. # spawn(command , options={}) -> Integer (147.0) -
引数を外部コマンドとして実行しますが、生成した 子プロセスの終了を待ち合わせません。生成した子プロセスのプロセスIDを返します。
...数の解釈
この形式では command が shell のメタ文字
//emlist{
* ? {} [] <> () ~ & | \ $ ; ' ` " \n
//}
を含む場合、shell 経由で実行されます。
そうでなければインタプリタから直接実行されます。
@param command コマンドを文字列で指定... -
Kernel
. # spawn(env , command , options={}) -> Integer (147.0) -
引数を外部コマンドとして実行しますが、生成した 子プロセスの終了を待ち合わせません。生成した子プロセスのプロセスIDを返します。
...数の解釈
この形式では command が shell のメタ文字
//emlist{
* ? {} [] <> () ~ & | \ $ ; ' ` " \n
//}
を含む場合、shell 経由で実行されます。
そうでなければインタプリタから直接実行されます。
@param command コマンドを文字列で指定... -
Kernel
. # system(command , options={}) -> bool | nil (133.0) -
引数を外部コマンドとして実行して、成功した時に真を返します。
...の解釈
この形式では command が shell のメタ文字
//emlist{
* ? {} [] <> () ~ & | \ $ ; ' ` " \n
//}
を含む場合、shell 経由で実行されます。
そうでなければインタプリタから直接実行されます。
@param command command コマンドを文字列で指......y]{
system("echo *") # => true
# fileA fileB fileC ...
//}
//emlist[exceptionオプションを指定][ruby]{
system("sad", exception: true) # => Errno::ENOENT (No such file or directory - sad)
system('ruby -e "exit(false)"', exception: true) # => RuntimeError (Command failed with... -
Kernel
. # system(env , command , options={}) -> bool | nil (133.0) -
引数を外部コマンドとして実行して、成功した時に真を返します。
...の解釈
この形式では command が shell のメタ文字
//emlist{
* ? {} [] <> () ~ & | \ $ ; ' ` " \n
//}
を含む場合、shell 経由で実行されます。
そうでなければインタプリタから直接実行されます。
@param command command コマンドを文字列で指......y]{
system("echo *") # => true
# fileA fileB fileC ...
//}
//emlist[exceptionオプションを指定][ruby]{
system("sad", exception: true) # => Errno::ENOENT (No such file or directory - sad)
system('ruby -e "exit(false)"', exception: true) # => RuntimeError (Command failed with...