George Keishing | e7a88fd | 2021-08-01 06:54:56 -0500 | [diff] [blame] | 1 | import subprocess |
| 2 | |
| 3 | |
| 4 | def execute_cmd(parms_string, quiet=False): |
| 5 | r""" |
| 6 | Run CLI standard tool or scripts. |
| 7 | |
| 8 | Description of variable: |
| 9 | parms_string Command to execute from the current SHELL. |
| 10 | quiet do not print tool error message if True |
| 11 | """ |
| 12 | |
| 13 | result = subprocess.run([parms_string], |
| 14 | stdout=subprocess.PIPE, |
| 15 | stderr=subprocess.PIPE, |
| 16 | shell=True, |
| 17 | universal_newlines=True) |
| 18 | |
| 19 | if result.stderr and not quiet: |
| 20 | print('\n\t\tERROR with %s ' % parms_string) |
| 21 | print('\t\t' + result.stderr) |
| 22 | |
| 23 | return result.stdout |