mltk.utils.shell_cmd¶
Shell command utility
See the source code on Github: mltk/utils/shell_cmd.py
Functions
|
Issue shell command |
- run_shell_cmd(cmd, cwd=None, env=None, outfile=None, line_processor=None, logger=None)[source]¶
Issue shell command
- Parameters:
cmd (
Union
[str
,Iterable
]) – The shell command. This may be a string or a list of stringscwd (
str
) – A path to a directory to change to before executing. If omitted then use the current working directoryenv (
dict
) – Dictionary of environment variables. If omitted then use current environment variablesoutfile (
IO
) – An opened, file-like object to write the shell command’s outputline_processor (
Callable
[[str
],str
]) – Callback to be invoked for each line returned by shell commandlogger (
Logger
) – Logger to dump shell command output
- Return type:
Tuple
[int
,str
]- Returns:
(retcode, retmsg)