meta data for this page
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revision | |||
| programming:python:run_system_command [2024/02/10 09:47] – niziak | programming:python:run_system_command [2024/02/23 08:46] (current) – niziak | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| + | ====== system / popen / exec ====== | ||
| + | In general: run system commands. | ||
| + | |||
| + | Current recommended way is to use [[https:// | ||
| + | <code python> | ||
| + | os.system | ||
| + | os.spawn* | ||
| + | </ | ||
| + | |||
| + | [[https:// | ||
| + | |||
| + | [[https:// | ||
| + | |||
| + | Features: | ||
| + | * possible to execute in shell: | ||
| + | * all command and params can be specified as string not list | ||
| + | * multiple commands can be executed at once; shell pipes usage possible | ||
| + | * configurable check for return codes or output | ||
| + | |||
| + | Parameters: | ||
| + | * [[https:// | ||
| + | * | ||
| + | |||
| + | Examples: | ||
| <code python> | <code python> | ||
| Line 14: | Line 38: | ||
| data = meta_data.decode(' | data = meta_data.decode(' | ||
| </ | </ | ||
| + | |||
| + | <code python> | ||
| + | return subprocess.check_output( | ||
| + | [self.FW_PRINTENV, | ||
| + | stderr=subprocess.STDOUT, | ||
| + | ... | ||
| + | return subprocess.check_call([self.FW_SETENV, | ||
| + | </ | ||
| + | |||