global::cmd
This module exposes the cmd
function, allowing vSMTP to execute system commands.
fn
build
fn build(parameters: Map) -> Cmd
Create a new command executor.
parameters
- a map of the following parameters:command
- the command to execute.timeout
- a duration after which the command subprocess will be killed.args
- an array of parameters passed to the executed program. (optional)user
- a user to run the command with. (optional)group
- a group to run the command with. (optional)
A service used to execute the a command.
- The service failed to parse the command parameters.
export const echo = cmd::build(#{
command: "echo",
args: ["-e", "'Hello World. \c This is vSMTP.'"],
timeout: "10s",
});
fn
run
fn run(cmd: Cmd) -> Map
fn run(cmd: Cmd, args: Array) -> Map
Execute the given command.
The command output.
- The service failed to execute the command.
const echo = cmd::build(#{
command: "echo",
args: ["-e", "'Hello World. \c This is vSMTP.'"],
timeout: "10s",
});
// the command executed will be:
// echo -e 'Hello World. \c This is vSMTP.'
echo.run();
// run the command with custom arguments (based one are replaced).
// echo -n 'Hello World.'
echo.run([ "-n", "'Hello World.'" ]);