#NEWLINE# def run_stderr( cmd , cwd = None , stdin = None , runas = None , shell = DEFAULT_SHELL , python_shell = None , env = None , clean_env = False , template = None , rstrip = True , umask = None , output_loglevel = 'debug' , log_callback = None , timeout = None , reset_system_locale = True , ignore_retcode = False , saltenv = 'base' , use_vt = False , **kwargs ) : #NEWLINE# #INDENT# '\n    Execute a command and only return the standard error\n\n    :param str cmd: The command to run. ex: \'ls -lart /home\'\n\n    :param str cwd: The current working directory to execute the command in,\n      defaults to /root\n\n    :param str stdin: A string of standard input can be specified for the\n      command to be run using the ``stdin`` parameter. This can be useful in cases\n      where sensitive information must be read from standard input.:\n\n    :param str runas: User to run script as. If running on a Windows minion you\n      must also pass a password\n\n    :param str password: Windows only. Pass a password if you specify runas.\n      This parameter will be ignored for other OS\'s\n\n      .. versionadded:: 2016.3.0\n\n    :param str shell: Shell to execute under. Defaults to the system default\n      shell.\n\n    :param bool python_shell: If False, let python handle the positional\n      arguments. Set to True to use shell features, such as pipes or redirection\n\n    :param list env: A list of environment variables to be set prior to\n      execution.\n\n        Example:\n\n        .. code-block:: yaml\n\n            salt://scripts/foo.sh:\n              cmd.script:\n                - env:\n                  - BATCH: \'yes\'\n\n        .. warning::\n\n            The above illustrates a common PyYAML pitfall, that **yes**,\n            **no**, **on**, **off**, **true**, and **false** are all loaded as\n            boolean ``True`` and ``False`` values, and must be enclosed in\n            quotes to be used as strings. More info on this (and other) PyYAML\n            idiosyncrasies can be found :doc:`here\n            </topics/troubleshooting/yaml_idiosyncrasies>`.\n\n        Variables as values are not evaluated. So $PATH in the following\n        example is a literal \'$PATH\':\n\n        .. code-block:: yaml\n\n            salt://scripts/bar.sh:\n              cmd.script:\n                - env: "PATH=/some/path:$PATH"\n\n        One can still use the existing $PATH by using a bit of Jinja:\n\n        .. code-block:: yaml\n\n            {% set current_path = salt[\'environ.get\'](\'PATH\', \'/bin:/usr/bin\') %}\n\n            mycommand:\n              cmd.run:\n                - name: ls -l /\n                - env:\n                  - PATH: {{ [current_path, \'/my/special/bin\']|join(\':\') }}\n\n    :param bool clean_env: Attempt to clean out all other shell environment\n      variables and set only those provided in the \'env\' argument to this\n      function.\n\n    :param str template: If this setting is applied then the named templating\n      engine will be used to render the downloaded file. Currently jinja, mako,\n      and wempy are supported\n\n    :param bool rstrip: Strip all whitespace off the end of output before it is\n      returned.\n\n    :param str umask: The umask (in octal) to use when running the command.\n\n    :param str output_loglevel: Control the loglevel at which the output from\n      the command is logged. Note that the command being run will still be logged\n      (loglevel: DEBUG) regardless, unless ``quiet`` is used for this value.\n\n    :param int timeout: A timeout in seconds for the executed process to return.\n\n    :param bool use_vt: Use VT utils (saltstack) to stream the command output\n      more interactively to the console and the logs. This is experimental.\n\n    .. note::\n      ``env`` represents the environment variables for the command, and\n      should be formatted as a dict, or a YAML string which resolves to a dict.\n\n    CLI Example:\n\n    .. code-block:: bash\n\n        salt \'*\' cmd.run_stderr "ls -l | awk \'/foo/{print \\$2}\'"\n\n    The template arg can be set to \'jinja\' or another supported template\n    engine to render the command arguments before execution.\n    For example:\n\n    .. code-block:: bash\n\n        salt \'*\' cmd.run_stderr template=jinja "ls -l /tmp/{{grains.id}} | awk \'/foo/{print \\$2}\'"\n\n    A string of standard input can be specified for the command to be run using\n    the ``stdin`` parameter. This can be useful in cases where sensitive\n    information must be read from standard input.:\n\n    .. code-block:: bash\n\n        salt \'*\' cmd.run_stderr "grep f" stdin=\'one\\ntwo\\nthree\\nfour\\nfive\\n\'\n    ' #NEWLINE# python_shell = _python_shell_default ( python_shell , kwargs . get ( '__pub_jid' , '' ) ) #NEWLINE# ret = _run ( cmd , runas = runas , cwd = cwd , stdin = stdin , shell = shell , python_shell = python_shell , env = env , clean_env = clean_env , template = template , rstrip = rstrip , umask = umask , output_loglevel = output_loglevel , log_callback = log_callback , timeout = timeout , reset_system_locale = reset_system_locale , ignore_retcode = ignore_retcode , use_vt = use_vt , saltenv = saltenv , pillarenv = kwargs . get ( 'pillarenv' ) , pillar_override = kwargs . get ( 'pillar' ) , password = kwargs . get ( 'password' , None ) ) #NEWLINE# log_callback = _check_cb ( log_callback ) #NEWLINE# lvl = _check_loglevel ( output_loglevel ) #NEWLINE# if ( lvl is not None ) : #NEWLINE# #INDENT# if ( ( not ignore_retcode ) and ( ret [ 'retcode' ] != 0 ) ) : #NEWLINE# #INDENT# if ( lvl < LOG_LEVELS [ 'error' ] ) : #NEWLINE# #INDENT# lvl = LOG_LEVELS [ 'error' ] #NEWLINE# #UNINDENT# msg = "Command '{0}' failed with return code: {1}" . format ( cmd , ret [ 'retcode' ] ) #NEWLINE# log . error ( log_callback ( msg ) ) #NEWLINE# #UNINDENT# if ret [ 'stdout' ] : #NEWLINE# #INDENT# log . log ( lvl , 'stdout: {0}' . format ( log_callback ( ret [ 'stdout' ] ) ) ) #NEWLINE# #UNINDENT# if ret [ 'stderr' ] : #NEWLINE# #INDENT# log . log ( lvl , 'stderr: {0}' . format ( log_callback ( ret [ 'stderr' ] ) ) ) #NEWLINE# #UNINDENT# if ret [ 'retcode' ] : #NEWLINE# #INDENT# log . log ( lvl , 'retcode: {0}' . format ( ret [ 'retcode' ] ) ) #NEWLINE# #UNINDENT# #UNINDENT# return ret [ 'stderr' ]