るりまサーチ

最速Rubyリファレンスマニュアル検索!
321件ヒット [1-100件を表示] (0.018秒)
トップページ > クエリ:shell[x] > 種類:モジュール関数[x]

別のキーワード

  1. shell/builtin-command new
  2. etc sc_shell
  3. shell/builtin-command each
  4. shell cd
  5. shell debug

ライブラリ

モジュール

キーワード

検索結果

<< 1 2 3 ... > >>

Shellwords.#shellescape(str) -> String (9101.0)

文字列を Bourne シェルのコマンドライン中で安全に使えるようにエスケープします。

...ープします。

@param str エスケープの対象となる文字列を指定します。
@return エスケープされた文字列を返します。

例:
require 'shellwords'

pattern = 'Jan 15'
puts "grep #{Shellwords.shellescape(pattern)} file"
# => grep Jan\ 15 file...

Shellwords.#shelljoin(array) -> String (9101.0)

配列の各要素である文字列に対して、Bourne シェルのコマンドライン中で安全に 使えるためのエスケープを適用し、空白文字を介してそれらを連結したコマンド ライン文字列を生成します。

...スケープには、Shellwords.#shellescape と
同じ規則が適用されます。

@param array エスケープ対象の文字列を要素とする配列を指定します。
@return エスケープ結果を連結した文字列を返します。

例:
require 'shellwords'

pattern =...
...'Jan 15'
file = 'file name with spaces'
puts Shellwords.shelljoin(['grep', pattern, file])
# => grep Jan\ 15 file\ name\ with\ spaces...

Shellwords.#shellsplit(line) -> [String] (9101.0)

Bourne シェルの単語分割規則に従った空白区切りの単語分割を行い、 単語 (文字列) の配列を返します。

...ォートが現れた場合に発生します。

例:
require 'shellwords'

p Shellwords.shellwords(%q{ foo bar "foo bar"\ baz 'foo bar' })
# => ["foo", "bar", "foo bar baz", "foo bar"]

p Shellwords.shellwords(%q{ A B C "D E F" "G","H I" })
# => ["A", "B", "C", "D...

Shellwords.#shellwords(line) -> [String] (9101.0)

Bourne シェルの単語分割規則に従った空白区切りの単語分割を行い、 単語 (文字列) の配列を返します。

...ォートが現れた場合に発生します。

例:
require 'shellwords'

p Shellwords.shellwords(%q{ foo bar "foo bar"\ baz 'foo bar' })
# => ["foo", "bar", "foo bar baz", "foo bar"]

p Shellwords.shellwords(%q{ A B C "D E F" "G","H I" })
# => ["A", "B", "C", "D...

Kernel.#exec(command, options={}) -> () (22.0)

引数で指定されたコマンドを実行します。

...マンド(あるいは shell)になるので、
起動に成功した場合、このメソッドからは戻りません。

=== 引数の解釈

この形式では command が shell のメタ文字
//emlist{
* ? {} [] <> () ~ & | \ $ ; ' ` " \n
//}
を含む場合、shell 経由で実行されま...

絞り込み条件を変える

Kernel.#exec(env, command, options={}) -> () (22.0)

引数で指定されたコマンドを実行します。

...マンド(あるいは shell)になるので、
起動に成功した場合、このメソッドからは戻りません。

=== 引数の解釈

この形式では command が shell のメタ文字
//emlist{
* ? {} [] <> () ~ & | \ $ ; ' ` " \n
//}
を含む場合、shell 経由で実行されま...

Kernel.#exec(env, program, *args, options={}) -> () (22.0)

引数で指定されたコマンドを実行します。

...行します。

プロセスの実行コードはそのコマンド(あるいは shell)になるので、
起動に成功した場合、このメソッドからは戻りません。

この形式では、常に shell を経由せずに実行されます。

exec(3) でコマンドを実行すると...
...更できます。
詳しくは Kernel.#spawn を参照してください。

=== 引数の解釈

この形式で呼び出した場合、空白や shell のメタキャラクタも
そのまま program の引数に渡されます。
先頭の引数が2要素の配列であった場合、第1要素...

Kernel.#exec(program, *args, options={}) -> () (22.0)

引数で指定されたコマンドを実行します。

...行します。

プロセスの実行コードはそのコマンド(あるいは shell)になるので、
起動に成功した場合、このメソッドからは戻りません。

この形式では、常に shell を経由せずに実行されます。

exec(3) でコマンドを実行すると...
...更できます。
詳しくは Kernel.#spawn を参照してください。

=== 引数の解釈

この形式で呼び出した場合、空白や shell のメタキャラクタも
そのまま program の引数に渡されます。
先頭の引数が2要素の配列であった場合、第1要素...

Timeout.#timeout(sec, exception_class = nil) {|i| ... } -> object (19.0)

ブロックを sec 秒の期限付きで実行します。 ブロックの実行時間が制限を過ぎたときは例外 Timeout::Error が発生します。

...コマンドのタイムアウト
require 'timeout'

# テスト用のシェルをつくる。
File.open("loop.sh", "w"){|fp|
fp.print <<SHELL_EOT
#!/bin/bash

S="scale=10"
M=32767

trap 'echo "$S; $m1/($m1+$m2)*4" | bc ; echo "count = $((m1+m2))" ; exit 0' INT
m1=0
m2=0

whi...
...M/$M)"
c=$(echo "$S;$x^2+$y^2 < 1.0" | bc)
echo $x $y $c
if [ $c -eq 1 ]
then
let m1++
else
let m2++
fi
done
SHELL
_EOT
}

File.chmod(0755, "loop.sh")
t = 10 # 10 秒でタイムアウト
begin
pid = nil
com = nil
Timeout.timeout(t) {...
...n("./loop.sh")
pid = com.pid
while line = com.gets
print line
end
}
rescue Timeout::Error => err
puts "timeout: shell execution."
Process.kill('SIGINT', pid)
printf "[result]\t%s", com.read
com.close unless com.nil?
end

#止まっているか確...
<< 1 2 3 ... > >>