execute¶
- execute(cmd, cwd=None, shell=False, executable=None, hide_win=True, check=True, capture_output=False, timeout=None, env=None)¶
Launch an external process.
- Parameters:
- cmdstr
Command line to execute, e.g.: “echo 42”
- cwdstr
Current directory of the executed command.
- shellbool, default=False
If set to True, the command is started in a shell (bash).
- executablestr, default=False
path to the shell. e.g. /bin/zsh.
- hide_winstr, default=True
Hide cmd.exe popup on windows platform.
- checkbool, default=True
If set to True: raise RuntimeError if return code of process != 0
- capture_outputbool, default=False
Whether the output/error streams will be captured
- timeoutint
Process timeout (Python >=3.3 only) On timeout and if psutil is available the children of the process are killed before the process itself
- envdict, default=None
Environment variables mapping for the new process
- Returns:
- cpsubprocess.CompletedProcess
Process state info
- Raises:
- RuntimeError
could not run
Examples
>>> import openturns.coupling_tools as ct >>> cp = ct.execute('echo 42', capture_output=True, shell=True) >>> cp.returncode 0 >>> int(cp.stdout) 42
Examples using the function¶
Link to a computer code with coupling tools
Link to a computer code with coupling tools