D 1.0   D 2.0
About Japanese Translation

www.digitalmars.com
Last update Fri May 16 23:02:39 2008

std.process

Authors:
Walter Bright, Andrei Alexandrescu

int system(string command);
コマンドシェルで command を実行します

Returns:
commandnull の場合、 コマンドシェルが存在すれば非ゼロ、しなければゼロを返します。commandnull でない場合、エラー時には -1、コマンドが実行されたときには command の終了コードを返します。

Note:
On Unix systems, the homonym C function (which is accessible to D programs as std.c.system) returns a code in the same format as waitpid, meaning that C programs must use the WEXITSTATUS macro to extract the actual exit code from the system call. D's system automatically extracts the exit status.

int execv(in string pathname, in string[] argv);
int execve(in string pathname, in string[] argv, in string[] envp);
int execvp(in string pathname, in string[] argv);
int execvpe(in string pathname, in string[] argv, in string[] envp);
pathname で指定されたプログラムを、引数 (argv) と環境変数 (envp) を与えて実行し、その終了ステータスを返します。 'p' のついたバージョンは、program の探索のために PATH 環境変数を参照します。

string shell(string cmd);
cmd をシェルで実行し、その標準出力を返します。 プロセスが実行できなかったときやエラーで終了したときは、 例外を投げます。

Example:
   auto tempFilename = chomp(shell("mcookie"));
   auto f = enforce(fopen(tempFilename), "w");
   scope(exit)
   {
       fclose(f) == 0 || assert(false);
       system("rm " ~ tempFilename);
   }
   ... use f ...


string getenv(in char[] name);
環境変数 name の値を文字列で取得します。 内部で std.c.stdlib.getenv を呼び出します。

void setenv(in char[] name, in char[] value, bool overwrite);
環境変数 name に値 value をセットします。 value が書き込まれた場合、または既に値が設定済みで overwritefalse の場合、正常終了します。そうでない場合、 例外を投げます。内部で std.c.stdlib.setenv を呼び出します。

void unsetenv(in char[] name);
Removes variable name from the environment. Calls std.c.stdlib.unsetenv internally.