別のキーワード
種類
- インスタンスメソッド (39)
- 特異メソッド (22)
- ライブラリ (11)
- 文書 (3)
ライブラリ
- ビルトイン (14)
-
drb
/ extservm (1) -
irb
/ cmd / nop (1) -
rubygems
/ command (1) - shell (14)
-
shell
/ command-processor (14) -
shell
/ filter (15) -
shell
/ system-command (1)
クラス
-
DRb
:: ExtServManager (1) -
Gem
:: Command (1) - IO (14)
-
IRB
:: ExtendCommand :: Nop (1) - Shell (14)
-
Shell
:: CommandProcessor (14) -
Shell
:: Filter (15) -
Shell
:: SystemCommand (1)
キーワード
- < (1)
- > (1)
- >> (1)
- Rubyで使われる記号の意味(正規表現の複雑な記号は除く) (1)
- [] (3)
-
alias
_ command (1) - cat (3)
-
def
_ system _ command (1) -
drb
/ extservm (1) - echo (3)
- foreach (1)
- getoptlong (1)
- glob (3)
-
install
_ system _ commands (1) - link (1)
- mkdir (1)
-
net
/ ftp (1) -
optparse
/ date (1) -
optparse
/ shellwords (1) -
optparse
/ time (1) -
optparse
/ uri (1) - out (3)
- popen (14)
- rdoc (1)
-
ruby 1
. 8 . 4 feature (1) -
ruby 1
. 9 feature (1) - rubygems (1)
- service (1)
- symlink (1)
- system (3)
- tee (3)
- test (3)
-
to
_ a (1) -
to
_ s (1) - transact (3)
- tsort (1)
-
unalias
_ command (1) -
undef
_ system _ command (1) -
win32
/ registry (1) - | (1)
検索結果
先頭5件
-
Shell
:: SystemCommand . new(sh , command , *opts) (63625.0) -
@todo
@todo
@param sh
@param command
@param opts -
IRB
:: ExtendCommand :: Nop . new(conf) -> IRB :: ExtendCommand :: Nop (63604.0) -
自身を初期化します。ユーザが直接使用するものではありません。
自身を初期化します。ユーザが直接使用するものではありません。
@param conf IRB::Context オブジェクトを指定します。 -
Shell
:: CommandProcessor . new(shell) (63304.0) -
@todo
@todo -
Shell
. def _ system _ command(command , path = command) -> nil (19066.0) -
Shell のメソッドとして command を登録します.
Shell のメソッドとして command を登録します.
OS上のコマンドを実行するにはまず, Shellのメソッドとして定義します.
注) コマンドを定義しなくとも直接実行できる Shell#system コマンドもあります.
@param command Shell のメソッドとして定義するコマンドを文字列で指定します。
@param path command のパスを指定します。
指定しない場合はcommand と同じになります。
例)
require 'shell'
Shell.def_system_command "ls"
# ls ... -
Shell
. undef _ system _ command(command) -> Shell :: CommandProcessor (19027.0) -
commandを削除します.
commandを削除します.
@param command 削除するコマンドの文字列を指定します。
動作例:
require 'shell'
Shell.def_system_command("ls")
# ls を定義
Shell.undef_system_command("ls")
# ls を 削除
sh = Shell.new
begin
sh.transact {
ls("-l").each {|l|
puts l
}
}
rescue NameError => err
puts ... -
Shell
. alias _ command(alias , command , *opts) { . . . } -> self (18763.0) -
コマンドの別名(エイリアス)を作成します。 コマンドが無い場合は、Shell.def_system_command などであらかじめ作成します.
コマンドの別名(エイリアス)を作成します。
コマンドが無い場合は、Shell.def_system_command などであらかじめ作成します.
@param alias エイリアスの名前を文字列で指定します.
@param command コマンド名を文字列で指定します.
@param opts command で指定したコマンドのオプションを指定します.
使用例: ls -la | sort -k 5 のような例。
require 'shell'
Shell.def_system_command("ls")
Shell.alias_command("lsla", "... -
Shell
. unalias _ command(alias) -> () (18460.0) -
commandのaliasを削除します.
commandのaliasを削除します.
@param alias 削除したいエイリアスの名前を文字列で指定します。
@raise NameError alias で指定したコマンドが無い場合に発生します。
使用例: ls -la | sort -k 5 のような例。
require 'shell'
Shell.def_system_command("ls")
Shell.alias_command("lsla", "ls", "-a", "-l")
Shell.def_system_command("sort")
sh = Shell.new
sh.trans... -
Shell
. install _ system _ commands(pre = "sys _ ") -> () (18319.0) -
system_path上にある全ての実行可能ファイルをShellに定義する. メソッ ド名は元のファイル名の頭にpreをつけたものとなる.
system_path上にある全ての実行可能ファイルをShellに定義する. メソッ
ド名は元のファイル名の頭にpreをつけたものとなる.
@param pre Shellに定義するメソッド名の先頭に付加される文字列を指定します。
使用例: ls -l | head -n 5 のような例。
require 'shell'
Shell.install_system_commands
sh = Shell.new
sh.verbose = false
sh.transact {
(sys_ls("-l") | sys_head("-n 5")).each {|l... -
ruby 1
. 9 feature (10441.0) -
ruby 1.9 feature ruby version 1.9.0 は開発版です。 以下にあげる機能は将来削除されたり互換性のない仕様変更がなされるかもしれません。 1.9.1 以降は安定版です。 バグ修正がメインになります。
ruby 1.9 feature
ruby version 1.9.0 は開発版です。
以下にあげる機能は将来削除されたり互換性のない仕様変更がなされるかもしれません。
1.9.1 以降は安定版です。
バグ修正がメインになります。
記号について(特に重要なものは大文字(主観))
* カテゴリ
* [ruby]: ruby インタプリタの変更
* [api]: 拡張ライブラリ API
* [lib]: ライブラリ
* [parser]: 文法の変更
* [regexp]: 正規表現の機能拡張
* [marshal]: Marshal ファイルのフォーマット変更
* ... -
Shell
:: CommandProcessor # system(command , *opts) -> Shell :: SystemCommand (9724.0) -
command を実行する.
command を実行する.
@param command 実行するコマンドのパスを文字列で指定します。
@param opts command のオプションを文字列で指定します。複数可。
使用例:
require 'shell'
Shell.verbose = false
sh = Shell.new
print sh.system("ls", "-l")
Shell.def_system_command("head")
sh.system("ls", "-l") | sh.head("-n 3") > STDOUT -
ruby 1
. 8 . 4 feature (9541.0) -
ruby 1.8.4 feature ruby 1.8.4 での ruby 1.8.3 からの変更点です。
ruby 1.8.4 feature
ruby 1.8.4 での ruby 1.8.3 からの変更点です。
掲載方針
*バグ修正の影響も含めて動作が変わるものを収録する。
*単にバグを直しただけのものは収録しない。
*ライブラリへの単なる定数の追加は収録しない。
以下は各変更点に付けるべきタグです。
記号について(特に重要なものは大文字(主観))
# * カテゴリ
# * [ruby]: ruby インタプリタの変更
# * [api]: 拡張ライブラリ API
# * [lib]: ライブラリ
* レベル
* [bug]: バグ修正
* [new]: 追加され... -
Shell
:: CommandProcessor # [](command , file1 , file2 = nil) -> bool | Time | Integer | nil (9343.0) -
Kernel.#test や FileTest のメソッドに処理を委譲します。
Kernel.#test や FileTest のメソッドに処理を委譲します。
@param command 数値、またはサイズが 1 の文字列の場合は Kernel.#test に処理委譲します。
2 文字以上の文字列の場合は FileTest のメソッドとして実行します。
@param file1 文字列でファイルへのパスを指定します。
@param file2 文字列でファイルへのパスを指定します。
require 'shell'
Shell.verbose = false
sh = Shell.new
begin
sh.m... -
Shell
:: CommandProcessor # test(command , file1 , file2 = nil) -> bool | Time | Integer | nil (9343.0) -
Kernel.#test や FileTest のメソッドに処理を委譲します。
Kernel.#test や FileTest のメソッドに処理を委譲します。
@param command 数値、またはサイズが 1 の文字列の場合は Kernel.#test に処理委譲します。
2 文字以上の文字列の場合は FileTest のメソッドとして実行します。
@param file1 文字列でファイルへのパスを指定します。
@param file2 文字列でファイルへのパスを指定します。
require 'shell'
Shell.verbose = false
sh = Shell.new
begin
sh.m... -
Gem
:: Command # merge _ options(new _ options) -> Hash (9322.0) -
与えられたオプションとデフォルトのオプションをマージします。 しかし、新しいオプションに同一のキーがあってもデフォルトのオプションは変更されません。
与えられたオプションとデフォルトのオプションをマージします。
しかし、新しいオプションに同一のキーがあってもデフォルトのオプションは変更されません。
@param new_options 新しいコマンドオプションをハッシュで指定します。 -
Shell
:: CommandProcessor # link(old , new) -> 0 (9322.0) -
File クラスにある同名のクラスメソッドと同じです.
File クラスにある同名のクラスメソッドと同じです.
@param old ファイル名を表す文字列を指定します。
@param new ファイル名を表す文字列を指定します。
@see File.link -
Shell
:: CommandProcessor # symlink(old , new) -> 0 (9322.0) -
File クラスにある同名のクラスメソッドと同じです.
File クラスにある同名のクラスメソッドと同じです.
@param old ファイル名を表す文字列を指定します。
@param new シンボリックリンクを表す文字列を指定します。
@see File.symlink -
Shell
:: CommandProcessor # cat(*files) -> Shell :: Filter (9037.0) -
実行すると, それらを内容とする Filter オブジェクトを返します.
実行すると, それらを内容とする Filter オブジェクトを返します.
@param files シェルコマンド cat に与えるファイル名を文字列で指定します。
動作例
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") >> "al... -
Shell
:: CommandProcessor # echo(*strings) -> Shell :: Filter (9037.0) -
実行すると, それらを内容とする Filter オブジェクトを返します.
実行すると, それらを内容とする Filter オブジェクトを返します.
@param strings シェルコマンド 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") >> "al... -
Shell
:: CommandProcessor # glob(pattern) -> Shell :: Filter (9037.0) -
実行すると, それらを内容とする Filter オブジェクトを返します.
実行すると, それらを内容とする Filter オブジェクトを返します.
@param pattern シェルコマンド glob に与えるパターンを指定します。
パターンの書式については、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|
... -
Shell
:: CommandProcessor # out(dev = STDOUT , &block) -> () (9037.0) -
Shell#transact を呼び出しその結果を dev に出力します。
Shell#transact を呼び出しその結果を dev に出力します。
@param dev 出力先をIO オブジェクトなどで指定します。
@param block transact 内部で実行するシェルを指定します。
使用例:
require 'shell'
Shell.def_system_command("head")
sh = Shell.new
File.open("out.txt", "w"){ |fp|
sh.out(fp) {
system("ls", "-l") | head("-n 3")
}
} -
Shell
:: CommandProcessor # tee(file) -> Shell :: Filter (9037.0) -
実行すると, それらを内容とする Filter オブジェクトを返します.
実行すると, それらを内容とする Filter オブジェクトを返します.
@param file シェルコマンドtee に与えるファイル名を文字列で指定します。
動作例
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... -
Shell
:: CommandProcessor # transact { . . . } -> object (9037.0) -
ブロック中で shell を self として実行します。
ブロック中で shell を self として実行します。
例:
require 'shell'
Shell.def_system_command("head")
sh = Shell.new
sh.transact{
system("ls", "-l") | head > STDOUT
# transact の中では、
# sh.system("ls", "-l") | sh.head > STDOUT と同じとなる。
} -
Shell
:: CommandProcessor # foreach(path = nil , &block) -> () (9019.0) -
pathがファイルなら, File#foreach pathがディレクトリなら, Dir#foreach の動作をします。
pathがファイルなら, File#foreach
pathがディレクトリなら, Dir#foreach
の動作をします。
@param path ファイルもしくはディレクトリのパスを文字列で指定します。
使用例
require 'shell'
Shell.verbose = false
sh = Shell.new
sh.foreach("/tmp"){|f|
puts f
} -
Shell
:: CommandProcessor # mkdir(*path) -> Array (9019.0) -
Dir.mkdirと同じです。 (複数可)
Dir.mkdirと同じです。 (複数可)
@param path 作成するディレクトリ名を文字列で指定します。
@return 作成するディレクトリの一覧の配列を返します。
使用例
require 'shell'
Shell.verbose = false
sh = Shell.new
begin
p sh.mkdir("foo") #=> ["foo"]
rescue => err
puts err
end -
Shell
# system(command , *opts) -> Shell :: SystemCommand (724.0) -
command を実行する.
command を実行する.
@param command 実行するコマンドのパスを文字列で指定します。
@param opts command のオプションを文字列で指定します。複数可。
使用例:
require 'shell'
Shell.verbose = false
sh = Shell.new
print sh.system("ls", "-l")
Shell.def_system_command("head")
sh.system("ls", "-l") | sh.head("-n 3") > STDOUT -
Shell
:: Filter # system(command , *opts) -> Shell :: SystemCommand (724.0) -
command を実行する.
command を実行する.
@param command 実行するコマンドのパスを文字列で指定します。
@param opts command のオプションを文字列で指定します。複数可。
使用例:
require 'shell'
Shell.verbose = false
sh = Shell.new
print sh.system("ls", "-l")
Shell.def_system_command("head")
sh.system("ls", "-l") | sh.head("-n 3") > STDOUT -
IO
. popen(env = {} , command , mode = "r" , opt={}) -> IO (385.0) -
サブプロセスを実行し、そのプロセスの標準入出力 との間にパイプラインを確立します。生成したパイプを IO オブジェクトとして返します。
サブプロセスを実行し、そのプロセスの標準入出力
との間にパイプラインを確立します。生成したパイプを IO オブジェクトとして返します。
p io = IO.popen("cat", "r+") # => #<IO:fd 4>
io.puts "foo"
io.close_write
p io.gets # => "foo\n"
サブプロセスを指定する方法は2通りあります。文字列を指定する場合と配列を指定する場合です。
文字列の場合は、シェルを経由して子プロセスを実行し、
配列の場合は、シェルを経由せずに子プロセスを実行します。
... -
IO
. popen(env = {} , command , mode = "r" , opt={}) {|f| . . . } -> object (385.0) -
サブプロセスを実行し、そのプロセスの標準入出力 との間にパイプラインを確立します。生成したパイプを IO オブジェクトとして返します。
サブプロセスを実行し、そのプロセスの標準入出力
との間にパイプラインを確立します。生成したパイプを IO オブジェクトとして返します。
p io = IO.popen("cat", "r+") # => #<IO:fd 4>
io.puts "foo"
io.close_write
p io.gets # => "foo\n"
サブプロセスを指定する方法は2通りあります。文字列を指定する場合と配列を指定する場合です。
文字列の場合は、シェルを経由して子プロセスを実行し、
配列の場合は、シェルを経由せずに子プロセスを実行します。
... -
Shell
# [](command , file1 , file2 = nil) -> bool | Time | Integer | nil (343.0) -
Kernel.#test や FileTest のメソッドに処理を委譲します。
Kernel.#test や FileTest のメソッドに処理を委譲します。
@param command 数値、またはサイズが 1 の文字列の場合は Kernel.#test に処理委譲します。
2 文字以上の文字列の場合は FileTest のメソッドとして実行します。
@param file1 文字列でファイルへのパスを指定します。
@param file2 文字列でファイルへのパスを指定します。
require 'shell'
Shell.verbose = false
sh = Shell.new
begin
sh.m... -
Shell
# test(command , file1 , file2 = nil) -> bool | Time | Integer | nil (343.0) -
Kernel.#test や FileTest のメソッドに処理を委譲します。
Kernel.#test や FileTest のメソッドに処理を委譲します。
@param command 数値、またはサイズが 1 の文字列の場合は Kernel.#test に処理委譲します。
2 文字以上の文字列の場合は FileTest のメソッドとして実行します。
@param file1 文字列でファイルへのパスを指定します。
@param file2 文字列でファイルへのパスを指定します。
require 'shell'
Shell.verbose = false
sh = Shell.new
begin
sh.m... -
Shell
:: Filter # [](command , file1 , file2 = nil) -> bool | Time | Integer | nil (343.0) -
Kernel.#test や FileTest のメソッドに処理を委譲します。
Kernel.#test や FileTest のメソッドに処理を委譲します。
@param command 数値、またはサイズが 1 の文字列の場合は Kernel.#test に処理委譲します。
2 文字以上の文字列の場合は FileTest のメソッドとして実行します。
@param file1 文字列でファイルへのパスを指定します。
@param file2 文字列でファイルへのパスを指定します。
require 'shell'
Shell.verbose = false
sh = Shell.new
begin
sh.m... -
Shell
:: Filter # test(command , file1 , file2 = nil) -> bool | Time | Integer | nil (343.0) -
Kernel.#test や FileTest のメソッドに処理を委譲します。
Kernel.#test や FileTest のメソッドに処理を委譲します。
@param command 数値、またはサイズが 1 の文字列の場合は Kernel.#test に処理委譲します。
2 文字以上の文字列の場合は FileTest のメソッドとして実行します。
@param file1 文字列でファイルへのパスを指定します。
@param file2 文字列でファイルへのパスを指定します。
require 'shell'
Shell.verbose = false
sh = Shell.new
begin
sh.m... -
drb
/ extservm (181.0) -
DRb::ExtServManager を定義しているライブラリ。
DRb::ExtServManager を定義しているライブラリ。
DRb::ExtServManager は drb で実現されたサービスブローカーです。
個々のサービスは drb/extserv で定義されている
DRb::ExtServ を用いて実装します。
DRb::ExtServManager
はクライアントの要求に応じて個々のサービスを
サブプロセスとして起動し、各サービスを表す DRb::ExtServ オブジェクト
をリモートオブジェクトとしてクライアントに渡します。
このライブラリは簡易的なもので、あまりメンテナンスもされていないので、
本格的な用途にはこのライブラリを参... -
rubygems (163.0)
-
RubyGems を扱うためのクラスやモジュールが定義されているライブラリです。
RubyGems を扱うためのクラスやモジュールが定義されているライブラリです。
===[a:gem_command] gem コマンドの使い方
$ gem help
RubyGems は Ruby のための高機能なパッケージ管理ツールです。
これはより多くの情報へのポインタを含んでいる基本的なヘルプメッセージです。
使用方法:
gem -h/--help
gem -v/--version
gem command [arguments...] [options...]
例:
... -
tsort (145.0)
-
tsort はトポロジカルソートと強連結成分に関するモジュールを提供します。
tsort はトポロジカルソートと強連結成分に関するモジュールを提供します。
=== Example
//emlist[][ruby]{
require 'tsort'
class Hash
include TSort
alias tsort_each_node each_key
def tsort_each_child(node, &block)
fetch(node).each(&block)
end
end
{1=>[2, 3], 2=>[3], 3=>[], 4=>[]}.tsort
#=> [3, 2, 1, 4]
{1=>[2], 2=>[3, 4... -
rdoc (109.0)
-
RDoc は Ruby のドキュメント生成を行うためのライブラリです。rdoc という ドキュメント生成のためのコマンドも含んでいます。
RDoc は Ruby のドキュメント生成を行うためのライブラリです。rdoc という
ドキュメント生成のためのコマンドも含んでいます。
このパッケージは RDoc と Markup というふたつのコンポーネントを含
んでいます。 RDoc とは Ruby のソースファイルに対するドキュメントを生成
するアプリケーションです。 JavaDoc と同様に、ソースを解析し、クラス、モ
ジュール、メソッドの定義を抜き出してきます(include,require もです)。そ
してこれらの内容とその直前に書かれたコメントを併合し、ドキュメントを出
力します(現在は HTML しか出力できませんが、こ... -
Rubyで使われる記号の意味(正規表現の複雑な記号は除く) (91.0)
-
Rubyで使われる記号の意味(正規表現の複雑な記号は除く) ex q num per and or plus minus ast slash hat sq period comma langl rangl eq tilde dollar at under lbrarbra lbra2rbra2 lbra3rbra3 dq colon ac backslash semicolon
Rubyで使われる記号の意味(正規表現の複雑な記号は除く)
ex q num per and or
plus minus ast slash hat sq
period comma langl rangl eq tilde
dollar at under lbrarbra
lbra2rbra2 lbra3rbra3 dq colon ac
backslash semicolon
===[a:ex] !
: !true
not 演算子。d:spec/operator#notを参照。
: 3 != 5
「等しくない」比較演算子。d:spec/operator#notを参... -
IO
. popen([env = {} , [cmdname , arg0] , *args , execopt={}] , mode = "r" , opt={}) -> IO (85.0) -
サブプロセスを実行し、そのプロセスの標準入出力 との間にパイプラインを確立します。生成したパイプを IO オブジェクトとして返します。
サブプロセスを実行し、そのプロセスの標準入出力
との間にパイプラインを確立します。生成したパイプを IO オブジェクトとして返します。
p io = IO.popen("cat", "r+") # => #<IO:fd 4>
io.puts "foo"
io.close_write
p io.gets # => "foo\n"
サブプロセスを指定する方法は2通りあります。文字列を指定する場合と配列を指定する場合です。
文字列の場合は、シェルを経由して子プロセスを実行し、
配列の場合は、シェルを経由せずに子プロセスを実行します。
... -
IO
. popen([env = {} , [cmdname , arg0] , *args , execopt={}] , mode = "r" , opt={}) {|f| . . . } -> object (85.0) -
サブプロセスを実行し、そのプロセスの標準入出力 との間にパイプラインを確立します。生成したパイプを IO オブジェクトとして返します。
サブプロセスを実行し、そのプロセスの標準入出力
との間にパイプラインを確立します。生成したパイプを IO オブジェクトとして返します。
p io = IO.popen("cat", "r+") # => #<IO:fd 4>
io.puts "foo"
io.close_write
p io.gets # => "foo\n"
サブプロセスを指定する方法は2通りあります。文字列を指定する場合と配列を指定する場合です。
文字列の場合は、シェルを経由して子プロセスを実行し、
配列の場合は、シェルを経由せずに子プロセスを実行します。
... -
IO
. popen([env = {} , cmdname , *args , execopt={}] , mode = "r" , opt={}) -> IO (85.0) -
サブプロセスを実行し、そのプロセスの標準入出力 との間にパイプラインを確立します。生成したパイプを IO オブジェクトとして返します。
サブプロセスを実行し、そのプロセスの標準入出力
との間にパイプラインを確立します。生成したパイプを IO オブジェクトとして返します。
p io = IO.popen("cat", "r+") # => #<IO:fd 4>
io.puts "foo"
io.close_write
p io.gets # => "foo\n"
サブプロセスを指定する方法は2通りあります。文字列を指定する場合と配列を指定する場合です。
文字列の場合は、シェルを経由して子プロセスを実行し、
配列の場合は、シェルを経由せずに子プロセスを実行します。
... -
IO
. popen([env = {} , cmdname , *args , execopt={}] , mode = "r" , opt={}) {|f| . . . } -> object (85.0) -
サブプロセスを実行し、そのプロセスの標準入出力 との間にパイプラインを確立します。生成したパイプを IO オブジェクトとして返します。
サブプロセスを実行し、そのプロセスの標準入出力
との間にパイプラインを確立します。生成したパイプを IO オブジェクトとして返します。
p io = IO.popen("cat", "r+") # => #<IO:fd 4>
io.puts "foo"
io.close_write
p io.gets # => "foo\n"
サブプロセスを指定する方法は2通りあります。文字列を指定する場合と配列を指定する場合です。
文字列の場合は、シェルを経由して子プロセスを実行し、
配列の場合は、シェルを経由せずに子プロセスを実行します。
... -
IO
. popen(env = {} , [[cmdname , arg0] , *args , execopt={}] , mode = "r" , opt={}) -> IO (85.0) -
サブプロセスを実行し、そのプロセスの標準入出力 との間にパイプラインを確立します。生成したパイプを IO オブジェクトとして返します。
サブプロセスを実行し、そのプロセスの標準入出力
との間にパイプラインを確立します。生成したパイプを IO オブジェクトとして返します。
p io = IO.popen("cat", "r+") # => #<IO:fd 4>
io.puts "foo"
io.close_write
p io.gets # => "foo\n"
サブプロセスを指定する方法は2通りあります。文字列を指定する場合と配列を指定する場合です。
文字列の場合は、シェルを経由して子プロセスを実行し、
配列の場合は、シェルを経由せずに子プロセスを実行します。
... -
IO
. popen(env = {} , [[cmdname , arg0] , *args , execopt={}] , mode = "r" , opt={}) {|f| . . . } -> object (85.0) -
サブプロセスを実行し、そのプロセスの標準入出力 との間にパイプラインを確立します。生成したパイプを IO オブジェクトとして返します。
サブプロセスを実行し、そのプロセスの標準入出力
との間にパイプラインを確立します。生成したパイプを IO オブジェクトとして返します。
p io = IO.popen("cat", "r+") # => #<IO:fd 4>
io.puts "foo"
io.close_write
p io.gets # => "foo\n"
サブプロセスを指定する方法は2通りあります。文字列を指定する場合と配列を指定する場合です。
文字列の場合は、シェルを経由して子プロセスを実行し、
配列の場合は、シェルを経由せずに子プロセスを実行します。
... -
IO
. popen(env = {} , [cmdname , *args , execopt={}] , mode = "r" , opt={}) -> IO (85.0) -
サブプロセスを実行し、そのプロセスの標準入出力 との間にパイプラインを確立します。生成したパイプを IO オブジェクトとして返します。
サブプロセスを実行し、そのプロセスの標準入出力
との間にパイプラインを確立します。生成したパイプを IO オブジェクトとして返します。
p io = IO.popen("cat", "r+") # => #<IO:fd 4>
io.puts "foo"
io.close_write
p io.gets # => "foo\n"
サブプロセスを指定する方法は2通りあります。文字列を指定する場合と配列を指定する場合です。
文字列の場合は、シェルを経由して子プロセスを実行し、
配列の場合は、シェルを経由せずに子プロセスを実行します。
... -
IO
. popen(env = {} , [cmdname , *args , execopt={}] , mode = "r" , opt={}) {|f| . . . } -> object (85.0) -
サブプロセスを実行し、そのプロセスの標準入出力 との間にパイプラインを確立します。生成したパイプを IO オブジェクトとして返します。
サブプロセスを実行し、そのプロセスの標準入出力
との間にパイプラインを確立します。生成したパイプを IO オブジェクトとして返します。
p io = IO.popen("cat", "r+") # => #<IO:fd 4>
io.puts "foo"
io.close_write
p io.gets # => "foo\n"
サブプロセスを指定する方法は2通りあります。文字列を指定する場合と配列を指定する場合です。
文字列の場合は、シェルを経由して子プロセスを実行し、
配列の場合は、シェルを経由せずに子プロセスを実行します。
... -
Shell
:: Filter # |(filter) -> object (73.0) -
パイプ結合を filter に対して行います。
パイプ結合を filter に対して行います。
@param filter Shell::Filter オブジェクトを指定します。
@return filter を返します。
使用例
require 'shell'
Shell.def_system_command("tail")
Shell.def_system_command("head")
Shell.def_system_command("wc")
sh = Shell.new
sh.transact {
i = 1
while i <= (cat("/etc/passwd") | wc(... -
IO
. popen("-" , mode = "r" , opt={}) -> IO (55.0) -
第一引数に文字列 "-" が指定された時、fork(2) を 行い子プロセスの標準入出力との間にパイプラインを確立します。 親プロセスでは IO オブジェクトを返し、子プロセスでは nil を返します。
第一引数に文字列 "-" が指定された時、fork(2) を
行い子プロセスの標準入出力との間にパイプラインを確立します。
親プロセスでは IO オブジェクトを返し、子プロセスでは
nil を返します。
io = IO.popen("-", "r+")
if io # parent
io.puts "foo"
p io.gets # => "child output: foo\n"
io.close
else # child
s = gets
print "child output: " + s
... -
IO
. popen("-" , mode = "r" , opt={}) {|io| . . . } -> object (55.0) -
第一引数に文字列 "-" が指定された時、fork(2) を 行い子プロセスの標準入出力との間にパイプラインを確立します。 親プロセスでは IO オブジェクトを返し、子プロセスでは nil を返します。
第一引数に文字列 "-" が指定された時、fork(2) を
行い子プロセスの標準入出力との間にパイプラインを確立します。
親プロセスでは IO オブジェクトを返し、子プロセスでは
nil を返します。
io = IO.popen("-", "r+")
if io # parent
io.puts "foo"
p io.gets # => "child output: foo\n"
io.close
else # child
s = gets
print "child output: " + s
... -
IO
. popen(env , "-" , mode = "r" , opt={}) -> IO (55.0) -
第一引数に文字列 "-" が指定された時、fork(2) を 行い子プロセスの標準入出力との間にパイプラインを確立します。 親プロセスでは IO オブジェクトを返し、子プロセスでは nil を返します。
第一引数に文字列 "-" が指定された時、fork(2) を
行い子プロセスの標準入出力との間にパイプラインを確立します。
親プロセスでは IO オブジェクトを返し、子プロセスでは
nil を返します。
io = IO.popen("-", "r+")
if io # parent
io.puts "foo"
p io.gets # => "child output: foo\n"
io.close
else # child
s = gets
print "child output: " + s
... -
IO
. popen(env , "-" , mode = "r" , opt={}) {|io| . . . } -> object (55.0) -
第一引数に文字列 "-" が指定された時、fork(2) を 行い子プロセスの標準入出力との間にパイプラインを確立します。 親プロセスでは IO オブジェクトを返し、子プロセスでは nil を返します。
第一引数に文字列 "-" が指定された時、fork(2) を
行い子プロセスの標準入出力との間にパイプラインを確立します。
親プロセスでは IO オブジェクトを返し、子プロセスでは
nil を返します。
io = IO.popen("-", "r+")
if io # parent
io.puts "foo"
p io.gets # => "child output: foo\n"
io.close
else # child
s = gets
print "child output: " + s
... -
DRb
:: ExtServManager # service(name) -> DRb :: ExtServ (37.0) -
name で指定したサービスに関連付けられた DRb::ExtServ オブジェクトを返します。
name で指定したサービスに関連付けられた DRb::ExtServ
オブジェクトを返します。
サービスを提供するプロセスが起動していない場合は、DRb::ExtServManager.command
で指定したプロセスを起動し、そのプロセスが DRb::ExtServ オブジェクトが
DRb::ExtServ.new によって ExtServManager に登録されるのを待ちます。
その後、登録されたオブジェクトを返します。
すでにプロセスが起動していた場合は、登録されている DRb::ExtServ オブジェクトを
返します。
DRb::ExtServ#stop_servic... -
Shell
# cat(*files) -> Shell :: Filter (37.0) -
実行すると, それらを内容とする Filter オブジェクトを返します.
実行すると, それらを内容とする Filter オブジェクトを返します.
@param files シェルコマンド cat に与えるファイル名を文字列で指定します。
動作例
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") >> "al... -
Shell
# echo(*strings) -> Shell :: Filter (37.0) -
実行すると, それらを内容とする Filter オブジェクトを返します.
実行すると, それらを内容とする Filter オブジェクトを返します.
@param strings シェルコマンド 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") >> "al... -
Shell
# glob(pattern) -> Shell :: Filter (37.0) -
実行すると, それらを内容とする Filter オブジェクトを返します.
実行すると, それらを内容とする Filter オブジェクトを返します.
@param pattern シェルコマンド glob に与えるパターンを指定します。
パターンの書式については、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|
... -
Shell
# out(dev = STDOUT , &block) -> () (37.0) -
Shell#transact を呼び出しその結果を dev に出力します。
Shell#transact を呼び出しその結果を dev に出力します。
@param dev 出力先をIO オブジェクトなどで指定します。
@param block transact 内部で実行するシェルを指定します。
使用例:
require 'shell'
Shell.def_system_command("head")
sh = Shell.new
File.open("out.txt", "w"){ |fp|
sh.out(fp) {
system("ls", "-l") | head("-n 3")
}
} -
Shell
# tee(file) -> Shell :: Filter (37.0) -
実行すると, それらを内容とする Filter オブジェクトを返します.
実行すると, それらを内容とする Filter オブジェクトを返します.
@param file シェルコマンドtee に与えるファイル名を文字列で指定します。
動作例
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... -
Shell
# transact { . . . } -> object (37.0) -
ブロック中で shell を self として実行します。
ブロック中で shell を self として実行します。
例:
require 'shell'
Shell.def_system_command("head")
sh = Shell.new
sh.transact{
system("ls", "-l") | head > STDOUT
# transact の中では、
# sh.system("ls", "-l") | sh.head > STDOUT と同じとなる。
} -
Shell
:: Filter # <(src) -> self (37.0) -
srcをフィルタの入力とする。 srcが, 文字列ならばファイルを, IOオブジェクトであれ ばそれをそのまま入力とする。
srcをフィルタの入力とする。 srcが, 文字列ならばファイルを, IOオブジェクトであれ
ばそれをそのまま入力とする。
@param src フィルタの入力を, 文字列もしくは,IO オブジェクトで指定します。
使用例
require 'shell'
Shell.def_system_command("head")
sh = Shell.new
sh.transact {
(sh.head("-n 30") < "/etc/passwd") > "ugo.txt"
} -
Shell
:: Filter # >(to) -> self (37.0) -
toをフィルタの出力とする。 toが, 文字列ならばファイルに, IOオブジェクトであれ ばそれをそのまま出力とする。
toをフィルタの出力とする。 toが, 文字列ならばファイルに, IOオブジェクトであれ
ばそれをそのまま出力とする。
@param to 出力先を指定します。文字列ならばファイルに,IOオブジェクトならばそれに出力します。
使用例
require 'shell'
Shell.def_system_command("tail")
sh = Shell.new
sh.transact {
(sh.tail("-n 3") < "/etc/passwd") > File.open("tail.out", "w")
#(sh.tail("-n 3") < "/e... -
Shell
:: Filter # >>(to) -> self (37.0) -
toをフィルタに追加する。 toが, 文字列ならばファイルに, IOオブジェクトであれば それをそのまま出力とする。
toをフィルタに追加する。 toが, 文字列ならばファイルに, IOオブジェクトであれば
それをそのまま出力とする。
@param to 出力先を指定します。文字列ならばファイルに、IOオブジェクトならばそれに出力します。
使用例
require 'shell'
Shell.def_system_command("tail")
sh = Shell.new
sh.transact {
(sh.tail("-n 3") < "/etc/passwd") >> "tail.out"
#(sh.tail("-n 3") < "/etc/passwd") >> ... -
Shell
:: Filter # cat(*files) -> Shell :: Filter (37.0) -
実行すると, それらを内容とする Filter オブジェクトを返します.
実行すると, それらを内容とする Filter オブジェクトを返します.
@param files シェルコマンド cat に与えるファイル名を文字列で指定します。
動作例
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") >> "al... -
Shell
:: Filter # echo(*strings) -> Shell :: Filter (37.0) -
実行すると, それらを内容とする Filter オブジェクトを返します.
実行すると, それらを内容とする Filter オブジェクトを返します.
@param strings シェルコマンド 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") >> "al... -
Shell
:: Filter # glob(pattern) -> Shell :: Filter (37.0) -
実行すると, それらを内容とする Filter オブジェクトを返します.
実行すると, それらを内容とする Filter オブジェクトを返します.
@param pattern シェルコマンド glob に与えるパターンを指定します。
パターンの書式については、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|
... -
Shell
:: Filter # out(dev = STDOUT , &block) -> () (37.0) -
Shell#transact を呼び出しその結果を dev に出力します。
Shell#transact を呼び出しその結果を dev に出力します。
@param dev 出力先をIO オブジェクトなどで指定します。
@param block transact 内部で実行するシェルを指定します。
使用例:
require 'shell'
Shell.def_system_command("head")
sh = Shell.new
File.open("out.txt", "w"){ |fp|
sh.out(fp) {
system("ls", "-l") | head("-n 3")
}
} -
Shell
:: Filter # tee(file) -> Shell :: Filter (37.0) -
実行すると, それらを内容とする Filter オブジェクトを返します.
実行すると, それらを内容とする Filter オブジェクトを返します.
@param file シェルコマンドtee に与えるファイル名を文字列で指定します。
動作例
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... -
Shell
:: Filter # to _ a -> [String] (37.0) -
実行結果を文字列の配列で返します。
実行結果を文字列の配列で返します。
require 'shell'
Shell.def_system_command("wc")
sh = Shell.new
puts sh.cat("/etc/passwd").to_a -
Shell
:: Filter # to _ s -> String (37.0) -
実行結果を文字列で返します。
実行結果を文字列で返します。
require 'shell'
Shell.def_system_command("wc")
sh = Shell.new
sh.transact {
puts (cat("/etc/passwd") | wc("-l")).to_s
} -
Shell
:: Filter # transact { . . . } -> object (37.0) -
ブロック中で shell を self として実行します。
ブロック中で shell を self として実行します。
例:
require 'shell'
Shell.def_system_command("head")
sh = Shell.new
sh.transact{
system("ls", "-l") | head > STDOUT
# transact の中では、
# sh.system("ls", "-l") | sh.head > STDOUT と同じとなる。
} -
getoptlong (37.0)
-
getoptlong は、GNU の getopt_long() とまったく同じ方式でコマンド 行オプションの解析を行う Ruby のライブラリです。
getoptlong は、GNU の getopt_long() とまったく同じ方式でコマンド
行オプションの解析を行う Ruby のライブラリです。
=== GNU getopt_long() とは?
GNU getopt_long() は、コマンド行オプションの解析を行う C の関数です。多
くの GNU ソフトウェアがこの関数を使用しています。GNU getopt_long() そし
て getoptlong には、以下のような特徴があります。
* 伝統的な一文字オプションに加えて、長いオプションに対応しています。長
いオプションは `-' の代わりに `--' で始まり... -
net
/ ftp (37.0) -
FTP プロトコルを扱うライブラリです。
FTP プロトコルを扱うライブラリです。
基本的には unix の ftp コマンドのような
command-line interface の FTP クライアントを使ったことのある
人にとってわかりやすいインターフェースになっています。
より「Ruby 的」であるインターフェースも用意しています。
FTP については 959、3659 を参考にしてください。
=== バイナリモードとテキストモード
FTP のデータ転送にはテキストモードとバイナリモード
があります。テキストモードで転送する場合には
改行を適宜CRLFに変換します。バイナリモードの場合は
一切の変換をしません。
通常... -
optparse
/ date (37.0) -
OptionParser#on で使用可能なクラスに Date と DateTime が 追加されます。 オプションの引数はそれぞれのクラスのインスタンスに変換されてから、 OptionParser#on のブロックに渡されます。
OptionParser#on で使用可能なクラスに Date と DateTime が
追加されます。
オプションの引数はそれぞれのクラスのインスタンスに変換されてから、
OptionParser#on のブロックに渡されます。
//emlist[][ruby]{
require 'optparse/date'
opts = OptionParser.new
opts.on("-d DATE", Date){|d|
p d.to_s #=> 2000-01-01
}
opts.parse!
# ruby command -d 2000/1/1
//} -
optparse
/ shellwords (37.0) -
OptionParser#on で使用可能な引数に Shellwords 追加されます。 オプションの引数は Shellwords.#shellwords によって配列に変換されてから、 OptionParser#on のブロックに渡されます。
OptionParser#on で使用可能な引数に Shellwords
追加されます。
オプションの引数は Shellwords.#shellwords によって配列に変換されてから、
OptionParser#on のブロックに渡されます。
//emlist[][ruby]{
require 'optparse/shellwords'
opts = OptionParser.new
opts.on("-s VAL", Shellwords){|a|
p a #=> ["hoge", "foo", "bar"]
}
opts.parse!
# ruby command -s hog... -
optparse
/ time (37.0) -
OptionParser#on で使用可能なクラスに Time が 追加されます。 オプションの引数は Time クラスのインスタンスに変換されてから、 OptionParser#on のブロックに渡されます。
OptionParser#on で使用可能なクラスに Time が
追加されます。
オプションの引数は Time クラスのインスタンスに変換されてから、
OptionParser#on のブロックに渡されます。
//emlist[][ruby]{
require 'optparse/time'
opts = OptionParser.new
opts.on("-t TIME", Time){|t|
p t #=> Sat, Jan 01 2000 00:00:00 +0900
}
opts.parse!
# ruby command -t '2000/01/01 00:00'
//}... -
optparse
/ uri (37.0) -
OptionParser#on で使用可能なクラスに URI が 追加されます。 オプションの引数は URI クラスのインスタンスに変換されてから、 OptionParser#on のブロックに渡されます。
OptionParser#on で使用可能なクラスに URI が
追加されます。
オプションの引数は URI クラスのインスタンスに変換されてから、
OptionParser#on のブロックに渡されます。
//emlist[][ruby]{
require 'optparse/uri'
opts = OptionParser.new
opts.on("-u URI", URI){|u|
p u #=> #<URI::HTTP:0x201267d4 URL:http://www.example.com>
}
opts.parse!
# ruby command -u http://w... -
win32
/ registry (37.0) -
win32/registry は Win32 プラットフォームでレジストリをアクセスするための ライブラリです。Win32 API の呼び出しに Win32API を使います。
win32/registry は Win32 プラットフォームでレジストリをアクセスするための
ライブラリです。Win32 API の呼び出しに Win32API を使います。
//emlist{
require 'win32/registry'
Win32::Registry::HKEY_CURRENT_USER.open('SOFTWARE\foo') do |reg|
value = reg['foo'] # 値の読み込み
value = reg['foo', Win32::Registry::REG_SZ] ...