Execute a shell command and return the command's return code. :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 unde
(
cmd,
cwd=None,
stdin=None,
runas=None,
group=None,
shell=DEFAULT_SHELL,
python_shell=None,
env=None,
clean_env=False,
template=None,
umask=None,
output_encoding=None,
output_loglevel="debug",
log_callback=None,
timeout=None,
reset_system_locale=True,
ignore_retcode=False,
saltenv=None,
use_vt=False,
password=None,
success_retcodes=None,
success_stdout=None,
success_stderr=None,
**kwargs,
)
| 2560 | |
| 2561 | |
| 2562 | def retcode( |
| 2563 | cmd, |
| 2564 | cwd=None, |
| 2565 | stdin=None, |
| 2566 | runas=None, |
| 2567 | group=None, |
| 2568 | shell=DEFAULT_SHELL, |
| 2569 | python_shell=None, |
| 2570 | env=None, |
| 2571 | clean_env=False, |
| 2572 | template=None, |
| 2573 | umask=None, |
| 2574 | output_encoding=None, |
| 2575 | output_loglevel="debug", |
| 2576 | log_callback=None, |
| 2577 | timeout=None, |
| 2578 | reset_system_locale=True, |
| 2579 | ignore_retcode=False, |
| 2580 | saltenv=None, |
| 2581 | use_vt=False, |
| 2582 | password=None, |
| 2583 | success_retcodes=None, |
| 2584 | success_stdout=None, |
| 2585 | success_stderr=None, |
| 2586 | **kwargs, |
| 2587 | ): |
| 2588 | """ |
| 2589 | Execute a shell command and return the command's return code. |
| 2590 | |
| 2591 | :param str cmd: The command to run. ex: ``ls -lart /home`` |
| 2592 | |
| 2593 | :param str cwd: The directory from which to execute the command. Defaults |
| 2594 | to the home directory of the user specified by ``runas`` (or the user |
| 2595 | under which Salt is running if ``runas`` is not specified). |
| 2596 | |
| 2597 | :param str stdin: A string of standard input can be specified for the |
| 2598 | command to be run using the ``stdin`` parameter. This can be useful in |
| 2599 | cases where sensitive information must be read from standard input. |
| 2600 | |
| 2601 | :param str runas: Specify an alternate user to run the command. The default |
| 2602 | behavior is to run as the user under which Salt is running. |
| 2603 | |
| 2604 | .. warning:: |
| 2605 | |
| 2606 | For versions 2018.3.3 and above on MacOS while using runas, |
| 2607 | to pass special characters to the command you need to escape |
| 2608 | the characters on the shell. |
| 2609 | |
| 2610 | Example: |
| 2611 | |
| 2612 | .. code-block:: bash |
| 2613 | |
| 2614 | cmd.retcode 'echo '\\''h=\\"baz\\"'\\''' runas=macuser |
| 2615 | |
| 2616 | :param str password: Windows only. The password for the account specified |
| 2617 | by ``runas``. Required only when the salt-minion is **not** running as |
| 2618 | SYSTEM or as an elevated Administrator. When Salt has sufficient |
| 2619 | privileges it can obtain a logon token for the target user through |
no test coverage detected