Pass in two strings, the first naming the executable language, aka - python2, python3, ruby, perl, lua, etc. the second string containing the code you wish to execute. The stdout will be returned. All parameters from :mod:`cmd.run_all ` except python_sh
(lang, code, cwd=None, args=None, **kwargs)
| 3474 | |
| 3475 | |
| 3476 | def exec_code(lang, code, cwd=None, args=None, **kwargs): |
| 3477 | """ |
| 3478 | Pass in two strings, the first naming the executable language, aka - |
| 3479 | python2, python3, ruby, perl, lua, etc. the second string containing |
| 3480 | the code you wish to execute. The stdout will be returned. |
| 3481 | |
| 3482 | All parameters from :mod:`cmd.run_all <salt.modules.cmdmod.run_all>` except python_shell can be used. |
| 3483 | |
| 3484 | CLI Example: |
| 3485 | |
| 3486 | .. code-block:: bash |
| 3487 | |
| 3488 | salt '*' cmd.exec_code ruby 'puts "cheese"' |
| 3489 | salt '*' cmd.exec_code ruby 'puts "cheese"' args='["arg1", "arg2"]' env='{"FOO": "bar"}' |
| 3490 | """ |
| 3491 | return exec_code_all(lang, code, cwd, args, **kwargs)["stdout"] |
| 3492 | |
| 3493 | |
| 3494 | def exec_code_all(lang, code, cwd=None, args=None, **kwargs): |
nothing calls this directly
no test coverage detected