るりまサーチ

最速Rubyリファレンスマニュアル検索!
156件ヒット [1-100件を表示] (0.015秒)
トップページ > クエリ:ls[x] > クエリ:system[x]

別のキーワード

  1. ftp ls
  2. net/ftp ls
  3. ls
  4. ls net/ftp
  5. ls net::ftp

検索結果

<< 1 2 > >>

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

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::CommandProcessor#system(command, *opts) -> Shell::SystemCommand (18231.0)

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 (18231.0)

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.def_system_command(command, path = command) -> nil (6143.0)

Shell のメソッドとして command を登録します.

...ドを実行するにはまず, Shellのメソッドとして定義します.
注) コマンドを定義しなくとも直接実行できる Shell#system コマンドもあります.

@param command Shell のメソッドとして定義するコマンドを文字列で指定します。

@param path...
...ます。

例)
require 'shell'
Shell.def_system_command "ls"
# ls を定義

Shell.def_system_command "sys_sort", "sort"
# sortコマンドをsys_sortとして定義

sh = Shell.new
sh.transact {
ls
.each { |l|
puts l
}
(ls("-l") | sys_sort("-k 5")).each {|l|
pu...

Shell.undef_system_command(command) -> Shell::CommandProcessor (6143.0)

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
put...

絞り込み条件を変える

Shell.install_system_commands(pre = "sys_") -> () (6135.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|
puts l
}
}...

FileUtils#sh(*cmd) {|result, status| ... } (3018.0)

与えられたコマンドを実行します。

...参照してください。


例:
sh %{ls -ltr}

sh 'ls', 'file with spaces'

# check exit status after command runs
sh %{grep pattern file} do |ok, res|
if ! ok
puts "pattern not found (status = #{res.exitstatus})"
end
end

@see Kernel.#exec, Kernel.#system...

FileUtils.#uptodate?(newer, older_list, options = nil) -> bool (3006.0)

newer が、older_list に含まれるすべてのファイルより新しいとき真。 存在しないファイルは無限に古いとみなされます。

...@param options どのようなオプションも指定することはできません。

@raise ArgumentError options にオプションを指定した場合に発生します。

//emlist[][ruby]{
require 'fileutils'
FileUtils.uptodate?('hello.o', ['hello.c', 'hello.h']) or system('make')
//}...

Readline.#readline(prompt = "", add_hist = false) -> String | nil (130.0)

prompt を出力し、ユーザからのキー入力を待ちます。 エンターキーの押下などでユーザが文字列を入力し終えると、 入力した文字列を返します。 このとき、add_hist が true であれば、入力した文字列を入力履歴に追加します。 何も入力していない状態で EOF(UNIX では ^D) を入力するなどで、 ユーザからの入力がない場合は nil を返します。

...adline.readline("> ")
(">"を表示し、入力待ちの状態になります。
ここでは「ls」を入力後、エンターキーを押したと想定します。)
> ls

p input # => "ls"

input = Readline.readline("> ", true)
(">"を表示し、入力待ちの状態になります...
...dline.readline
p buf
end
rescue Interrupt
system
("stty", stty_save)
exit
end

例: INTシグナルを捕捉して、端末状態を復帰する。

require 'readline'

stty_save = `stty -g`.chomp
trap("INT") { system "stty", stty_save; exit }

while buf = Readline.rea...

Benchmark.#benchmark(caption = "", label_width = nil, fmtstr = nil, *labels) {|rep| ...} -> [Benchmark::Tms] (118.0)

Benchmark::Report オブジェクトを生成し、それを引数として与えられたブロックを実行します。

...am labels ブロックが Benchmark::Tms オブジェクトの配列を返す場合に指定します。

=== フォーマット文字列

フォーマット文字列として以下が使用できます。

: %u
user CPU time で置き換えられます。Benchmark::Tms#utime
: %y
system
CPU ti...
...stem")。Benchmark::Tms#stime
: %U
子プロセスの user CPU time で置き換えられます。Benchmark::Tms#cutime
: %Y
子プロセスの system CPU time で置き換えられます。Benchmark::Tms#cstime
: %t
total CPU time で置き換えられます。Benchmark::Tms#total
: %r
...
....times do ; a = "1"; end }
tu = x.report("upto:") { 1.upto(n) do ; a = "1"; end }

[tf+tt+tu, (tf+tt+tu)/3]
end

#=>
#
# user system total real
# for: 1.016667 0.016667 1.033333 ( 0.485749)
# times: 1.450000 0.016667 1.466667 ( 0.681367)
# upto:...

絞り込み条件を変える

Benchmark.#bm(label_width = 0, *labels) {|rep| ... } -> [Benchmark::Tms] (118.0)

Benchmark.#benchmark メソッドの引数を簡略化したものです。

...たものです。

Benchmark.#benchmark メソッドと同様に働きます。

@param label_width ラベルの幅を指定します。
@param labels ブロックが Benchmark::Tms オブジェクトの配列を返す場合に指定します。

//emlist[][ruby]{
require 'benchmark'

n = 50000...
...eport { for i in 1..n; a = "1"; end }
x.report { n.times do ; a = "1"; end }
x.report { 1.upto(n) do ; a = "1"; end }
end

#=>
#
# user system total real
# 1.033333 0.016667 1.016667 ( 0.492106)
# 1.483333 0.000000 1.483333 ( 0.694605)
# 1.516667 0.000000 1.51...
..."1"; end }
x.report("times:") { n.times do ; a = "1"; end }
x.report("upto:") { 1.upto(n) do ; a = "1"; end }
end

#=>
# user system total real
# for: 1.050000 0.000000 1.050000 ( 0.503462)
# times: 1.533333 0.016667 1.550000 ( 0.735473)
# upto:...

Shell.alias_command(alias, command, *opts) {...} -> self (46.0)

コマンドの別名(エイリアス)を作成します。 コマンドが無い場合は、Shell.def_system_command などであらかじめ作成します.

...l.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
}
}...
<< 1 2 > >>