Created
December 23, 2019 21:28
-
-
Save hamzamu/dc0aa206837b4d0d8de6701d06877832 to your computer and use it in GitHub Desktop.
Red: Execute external and shell command
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
http://www.red-by-example.org/#call | |
The word call executes a shell command to run another process. | |
The argument is: | |
A command [string! file!] - A shell command or an executable file. | |
Refinements | |
/wait - Runs command and waits for exit. | |
/show - Force the display of system's shell window (Windows only). | |
/console - Runs command with I/O redirected to console (CLI console only at present). | |
/shell - Forces command to be run from shell. | |
/input - we provide a [string! file! binary!], which will be redirected to stdin. | |
/output - we provide a [string! file! binary!] which will | |
receive the redirected stdout from the command. Note that the | |
output is appended. | |
If you don't want this, clear the destination(or delete the file, for example). | |
/error - as /output, but redirects stderr. | |
(Awaiting additional documentation by red-by-example team.) | |
--- | |
https://www.rosettacode.org/wiki/Execute_a_system_command#Red | |
REBOL | |
; Capture output to string variable: | |
x: "" call/output "dir" x | |
print x | |
; The 'console' refinement displays the command output on the REBOL command line. | |
call/console "dir *.r" | |
call/console "ls *.r" | |
call/console "pause" | |
; The 'shell' refinement may be necessary to launch some programs. | |
call/shell "notepad.exe" | |
Red | |
call/show %pause ;The /show refinement forces the display of system's shell window (Windows only). | |
call/show %dir | |
call/show %notepad.exe | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment