MCPcopy Create free account
hub / github.com/saltstack/salt / run_stdout

Function run_stdout

salt/modules/cmdmod.py:1778–2017  ·  view source on GitHub ↗

Execute a command, and only return the standard out :param str cmd: The command to run. ex: ``ls -lart /home`` :param str cwd: The directory from which to execute the command. Defaults to the home directory of the user specified by ``runas`` (or the user under which Sa

(
    cmd,
    cwd=None,
    stdin=None,
    runas=None,
    group=None,
    shell=DEFAULT_SHELL,
    python_shell=None,
    env=None,
    clean_env=False,
    template=None,
    rstrip=True,
    umask=None,
    output_encoding=None,
    output_loglevel="debug",
    log_callback=None,
    hide_output=False,
    timeout=None,
    reset_system_locale=True,
    ignore_retcode=False,
    saltenv=None,
    use_vt=False,
    password=None,
    prepend_path=None,
    success_retcodes=None,
    success_stdout=None,
    success_stderr=None,
    **kwargs,
)

Source from the content-addressed store, hash-verified

1776
1777
1778def run_stdout(
1779 cmd,
1780 cwd=None,
1781 stdin=None,
1782 runas=None,
1783 group=None,
1784 shell=DEFAULT_SHELL,
1785 python_shell=None,
1786 env=None,
1787 clean_env=False,
1788 template=None,
1789 rstrip=True,
1790 umask=None,
1791 output_encoding=None,
1792 output_loglevel="debug",
1793 log_callback=None,
1794 hide_output=False,
1795 timeout=None,
1796 reset_system_locale=True,
1797 ignore_retcode=False,
1798 saltenv=None,
1799 use_vt=False,
1800 password=None,
1801 prepend_path=None,
1802 success_retcodes=None,
1803 success_stdout=None,
1804 success_stderr=None,
1805 **kwargs,
1806):
1807 """
1808 Execute a command, and only return the standard out
1809
1810 :param str cmd: The command to run. ex: ``ls -lart /home``
1811
1812 :param str cwd: The directory from which to execute the command. Defaults
1813 to the home directory of the user specified by ``runas`` (or the user
1814 under which Salt is running if ``runas`` is not specified).
1815
1816 :param str stdin: A string of standard input can be specified for the
1817 command to be run using the ``stdin`` parameter. This can be useful in
1818 cases where sensitive information must be read from standard input.
1819
1820 :param str runas: Specify an alternate user to run the command. The default
1821 behavior is to run as the user under which Salt is running.
1822
1823 .. warning::
1824
1825 For versions 2018.3.3 and above on MacOS while using runas,
1826 to pass special characters to the command you need to escape
1827 the characters on the shell.
1828
1829 Example:
1830
1831 .. code-block:: bash
1832
1833 cmd.run_stdout 'echo '\\''h=\\"baz\\"'\\''' runas=macuser
1834
1835 :param str password: Windows only. The password for the account specified

Callers 1

powershellFunction · 0.85

Calls 3

_python_shell_defaultFunction · 0.85
_runFunction · 0.70
getMethod · 0.45

Tested by

no test coverage detected