1import subprocess
2
3
4def 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
24