pzLib / erlcmd

a simple tool function like os:cmd return with exit status code of process.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

erlcmd

Erlcmd includes a simple tool function cmd:run. It likes os:cmd but returns exit status code and stdio output.

How to use

Download src/cmd.erl to your local disk then run:

Exe = os:find_executable("ls"),
CmdLine = Exe ++ " -a ./src",
{ok, ExitStatus, Output} = cmd:run(CmdLine, 1000),
io:format("exit status code: ~p~noutput: ~n~s", [ExitStatus, Output]).

Or like this:

Exe = os:find_executable("ls"),
{ok, ExitStatus, Output} = cmd:run(Exe, ["-a", "./src"], 5000), 
io:format("exit status code: ~p~noutput: ~n~s", [ExitStatus, Output]).

rebar.config

Add the following script into your rebar.config if you wanna manage your project by rebar.

{deps, [
    {erlcmd, "*", {git, "https://github.com/pzlib/erlcmd.git", {tag, "0.1.0"}}}
]}.

About

a simple tool function like os:cmd return with exit status code of process.

License:Apache License 2.0


Languages

Language:Erlang 100.0%