るりまサーチ

最速Rubyリファレンスマニュアル検索!
60件ヒット [1-60件を表示] (0.285秒)
トップページ > クエリ:@[x] > クラス:Shell[x] > ライブラリ:shell[x] > クエリ:def_system_command[x]

別のキーワード

  1. _builtin new
  2. _builtin inspect
  3. _builtin []
  4. _builtin to_s
  5. _builtin each

キーワード

検索結果

Shell.def_system_command(command, path = command) -> nil (18128.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
.def_system_command "sys_sort", "sort"
# sortコマン...

Shell.undef_system_command(command) -> Shell::CommandProcessor (6115.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...

Shell.alias_command(alias, command, *opts) {...} -> self (49.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", "ls", "-a", "-l")
Shell
.def_system_command("sort")
sh = Shell.new
sh.transact {
(lsla | sort("-k 5")).each {|l|
puts l
}
}...

Shell.unalias_command(alias) -> () (27.0)

commandのaliasを削除します.

...ます.

@
param alias 削除したいエイリアスの名前を文字列で指定します。

@
raise NameError alias で指定したコマンドが無い場合に発生します。

使用例: ls -la | sort -k 5 のような例。
require 'shell'
Shell
.def_system_command("ls")
Shell
.alias_co...
...mmand("lsla", "ls", "-a", "-l")
Shell
.def_system_command("sort")
sh = Shell.new
sh.transact {
(lsla | sort("-k 5")).each {|l|
puts l
}
}
Shell
.unalias_command("lsla")
begin
Shell
.unalias_command("lsla")
rescue NameError => err
puts err
end...

Shell#glob(pattern) -> Shell::Filter (21.0)

実行すると, それらを内容とする 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|
echo(l) | tee(file + ".tee") >> "all.tee"
}
}
}

@
see Dir.[]...

絞り込み条件を変える

Shell#out(dev = STDOUT, &block) -> () (21.0)

Shell#transact を呼び出しその結果を dev に出力します。

...
Shell
#transact を呼び出しその結果を dev に出力します。

@
param dev 出力先をIO オブジェクトなどで指定します。

@
param block transact 内部で実行するシェルを指定します。


使用例:
require 'shell'
Shell
.def_system_command("head")
sh = Shell...

Shell#system(command, *opts) -> Shell::SystemCommand (21.0)

command を実行する.

....

@
param command 実行するコマンドのパスを文字列で指定します。

@
param opts command のオプションを文字列で指定します。複数可。

使用例:

require 'shell'
Shell
.verbose = false
sh = Shell.new

print sh.system("ls", "-l")
Shell
.def_system_command(...

Shell#cat(*files) -> Shell::Filter (15.0)

実行すると, それらを内容とする Filter オブジェクトを返します.

...を内容とする Filter オブジェクトを返します.

@
param files シェルコマンド cat に与えるファイル名を文字列で指定します。

動作例
require 'shell'
Shell
.def_system_command("head")
sh = Shell.new
sh.transact {
glob("*.txt").to_a.each { |file|...

Shell#echo(*strings) -> Shell::Filter (15.0)

実行すると, それらを内容とする Filter オブジェクトを返します.

...らを内容とする Filter オブジェクトを返します.

@
param strings シェルコマンド echo に与える引数を文字列で指定します。

動作例
require 'shell'
Shell
.def_system_command("head")
sh = Shell.new
sh.transact {
glob("*.txt").to_a.each { |file|
f...

Shell#tee(file) -> Shell::Filter (15.0)

実行すると, それらを内容とする Filter オブジェクトを返します.

...を内容とする Filter オブジェクトを返します.

@
param file シェルコマンドtee に与えるファイル名を文字列で指定します。

動作例
require 'shell'
Shell
.def_system_command("head")
sh = Shell.new
sh.transact {
glob("*.txt").to_a.each { |file|...

絞り込み条件を変える