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 (
Optional
[str
]) – A path to a directory to change to before executing. If omitted then use the current working directoryenv (
Optional
[dict
]) – Dictionary of environment variables. If omitted then use current environment variablesoutfile (
Optional
[IO
]) – An opened, file-like object to write the shell command’s outputline_processor (
Optional
[Callable
[[str
],str
]]) – Callback to be invoked for each line returned by shell commandlogger (
Optional
[Logger
]) – Logger to dump shell command output
- Return type:
Tuple
[int
,str
]- Returns:
(retcode, retmsg)