proc.run
The proc.run module provides access to external programs.
Accessing Programs
Use proc.run as a namespace to access programs by name:
Or import specific programs:
Or call it with the program as a first argument:
Program Execution
When a program object is called, it spawns the external program with the given
arguments. Arguments are converted to strings using
std.arg.
I/O Redirection
Programs participate in Do's I/O system:
- Program stdout is connected to the current output
- Program stdin is connected to the current input
This means programs work naturally in pipelines:
import strand
let result = strand.pipeline
do run.cat /etc/passwd
do run.grep nologin
do strand.each do |line| [...line.split ":"]
do strand.collect()
Capturing Output
Use sub to capture a program's output as a
string:
Environment
Programs inherit the current environment from sys.env. Use
the env function to set variables for a specific
invocation:
Program Methods
which()
Returns the resolved path to the program executable, if found.