Skip to main content

Execute Program

Synopsis

这个操作符只执行一个命令the shell of the underlying operating system. It can execute any system command or external program.

Description

This operator executes a system command. The command and all its arguments are specified by thecommandparameter. Please note that the command is system dependent. The standard output stream of the process can be redirected to the log file by enabling thelog stdoutparameter. The standard error stream of the process can be redirected to the log file by enabling thelog stderrparameter.

In Windows / MS DOS, simple commands should be preceded by 'cmd /c' call, e.g. 'cmd /c notepad'. Just writing 'notepad' in thecommandparameter will also work in case you are executing a program and not just a shell command. Then Windows opens a new shell, executes the command, and closes the shell again. However, Windows 7 may not open a new shell, it just executes the command. Another option would be to precede the command with 'cmd /c start' which opens the shell and keeps it open. The rest of the process will not be executed until the shell is closed by the user. Please study the attached Example Processes for more information.

CAUTION: Due to a Java bug on Windows / MS DOS the operator is only able to stop first level child processes. For example: When stopping the operator that was started with a command containing a preceeding 'cmd /c', only the direct child process (the shell) will be closed but processes started by these shell will still be running detached from RapidMiner.

The JavaProcessBuilderis used for building and executing the command. Characters that have special meaning on the shell e.g. the pipe symbol or brackets and braces do not have a special meaning to Java. Please note, that this Java method parses the string into tokens before it is executed. These tokens are not interpreted by a shell. If the desired command involves piping, redirection or other shell features, it is best to create a small shell script to handle this.

Input

in

A file object sent to this port will be piped to the standard input (stdin) of the process.

通过

It is not compulsory to connect any object with this port. Any object connected at this port is delivered without any modifications to the output port. This operator can have multiple inputs. When one input is connected, another通过input port becomes available which is ready to accept another input (if any). The order of inputs remains the same. The object supplied at the first通过input port of the Execute Program operator is available at the first通过output port.

Output

out

If connected, the standard output stream (stdout) generated by this process will be delivered as a file object.

err

If connected, the standard error stream (stderr) generated by this process will be delivered as a file object.

通过

The objects that were given as input are passed without changing to the output through this port. It is not compulsory to connect this port to any other port, the command is executed even if this port is left without connections. The Execute Program operator can have multiple outputs. When one output is connected, another通过output port becomes available which is ready to deliver another output (if any). The order of outputs remains the same. The object delivered at the first通过input port of the Execute Program operator is delivered at the first通过output port

Parameters

Command

This parameter specifies the command to be executed.

Log stdout

If set to true, thestdoutstream (standard output stream) of the command is redirected to the log file. Only available ifoutport is not connected.

Log stderr

If set to true, thestderrstream (standard error stream) of the command is redirected to the log file. Only available iferrport is not connected.

Working directory

Defines the working directory for the command. If no working directory is defined the working directory of the current RapidMiner process is used.

Env variables

Allows to set environment variables for the specified command. If an environment variable is defined multiple times, the last defined variable will be used.