Scilab Website | Contribute with GitLab | Mailing list archives | ATOMS toolboxes
Scilab Online Help
6.1.0 - 日本語

Change language to:
English - Français - Português - Русский

Please note that the recommended version of Scilab is 2024.0.0. This page might be outdated.
See the recommended documentation of this function

Scilabヘルプ >> 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に誤った命令が含まれていると、

  • repが ""に設定されています.
  • 出力変数msgerrを使用すると、 通常はOS端末に表示されるエラーメッセージがキャッチされて格納されます。 それ以外の場合は、OSエラーがScilabコンソールに表示されます。
  • 誤った命令の後の残りの命令は無視される。
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')

参照

  • unix_s — Windows、LinuxまたはMacOSの命令を静かに実行する
  • unix_w — いくつかのWindows、LinuxまたはMacOS命令を実行し、結果をScilabコンソールに表示する
  • unix_x — いくつかのWindows、LinuxまたはMacOS命令を実行する: 結果はポップアップメッセージボックスに表示される
  • host — executes a Windows, Linux, or MacOS command
  • getos — オペレーティングシステムの名前とバージョンを返す
  • setenv — 環境変数の値を設定e
  • powershell — executes a command with the Windows powershell interpreter (Windows only)
  • List of MS Windows exit codes
Report an issue
<< setenv OS_commands unix_s >>

Copyright (c) 2022-2023 (Dassault Systèmes)
Copyright (c) 2017-2022 (ESI Group)
Copyright (c) 2011-2017 (Scilab Enterprises)
Copyright (c) 1989-2012 (INRIA)
Copyright (c) 1989-2007 (ENPC)
with contributors
Last updated:
Tue Feb 25 08:53:22 CET 2020