"Shell" (External Evaluation System)
ExternalEvaluate Usage
- ExternalEvaluate["Shell",code] executes a string in an operating system shell and returns the result as a Wolfram Language expression.
- ExternalEvaluate["Shell"form,code] executes the command string and returns the result in the specified form. Possible specifications for form are "Expression", "StandardOutput", "StandardError", "ExitCode" and "Association".
Examples
open allclose allBasic Examples (1)
Run a command in your default shell and return the result:
If a command "ExitCode" is not 0, a Failure object is returned:
Type > to get a Shell code cell that uses ExternalEvaluate to evaluate:
Scope (3)
Evaluate a command and return the result:
Extract the "ExitCode" from the result:
Extract the original command from the result:
Extract the "StandardOutput" and "StandardError" from the result:
Use "ReturnType" to specify a different return type:
Use File to run arbitrary binary or script files:
Applications (1)
Properties & Relations (2)
Use FindExternalEvaluators to find all available targets in your machine:
Use "Target" to manually specify a shell on your machine:
Powershell.exe is a valid "Target" on a Windows system:
RunProcess can also be used to execute shell commands, but it does not print output interactively:
Possible Issues (2)
ExternalEvaluate is unable to interrupt if the program is asking for input:
When running external commands that are requiring user input, it is advised to run them in a non-interactive mode:
ExternalEvaluate is printing output in real time: