<< setenv OS_commands unix_s >>

Scilab Help >> Input/Output functions > OS_commands > unix_g

unix_g

いくつかのWindows、LinuxまたはMacOS命令を実行し、変数で出力する

呼び出し手順

rep = unix_g(commands)
[rep, status] = unix_g(commands)
[rep, status, msgerr] = unix_g(commands)

パラメータ

commands

文字列

rep

文字列の列ベクトル (標準出力)

status

整数, エラーステータス. エラーが発生しない場合, status=0

msgerr

テキストの列:エラーメッセージ。

説明

unix_g()は、オペレーティングシステム(OS)(sh、 Linuxではcmd.exe)のコマンドインタープリタの新しいセッションを開き、 等..)。 次に、commandsがOSインタプリタに送信され、その命令が処理されます。 処理によって得られた標準出力とエラーメッセージが受信され、インタプリタセッションが閉じられます。

開いているインタプリタの開始作業ディレクトリと環境変数は、 host()ページで説明されているように定義されています。

標準出力は変数repに記録されます。.

commandsに誤った命令が含まれていると、

The effects of valid instructions processed before the erroneous one remain actual (for instance, deleted files). However, their standard output is lost. 複数の命令を持つcommandsはお勧めできません。 それらはデバッグするのがより困難です。

function d=DIR(path)
  path = pathconvert(path,%t,%t)
  if getos() == 'Windows' then
    d = unix_g('dir '+path)
  else
    d = unix_g('ls '+path)
  end
endfunction

DIR('SCI/etc')

参照


Report an issue
<< setenv OS_commands unix_s >>