diff --git a/common/command.py b/common/command.py index fe90982d..a3770e43 100644 --- a/common/command.py +++ b/common/command.py @@ -30,8 +30,7 @@ def __init__(self, stdio=None): def run(self, cmd): try: self.stdio.verbose("[local host] run cmd = [{0}] on localhost".format(cmd)) - cmd = "bash -c '{0}'".format(cmd) - out = subprocess.Popen(cmd, stderr=subprocess.STDOUT, stdout=subprocess.PIPE, shell=True) + out = subprocess.Popen(cmd, stderr=subprocess.STDOUT, stdout=subprocess.PIPE, shell=True, executable='/bin/bash') stdout, stderr = out.communicate() if stderr: self.stdio.error("run cmd = [{0}] on localhost, stderr=[{1}]".format(cmd, stderr)) @@ -42,8 +41,7 @@ def run(self, cmd): def run_get_stderr(self, cmd): try: self.stdio.verbose("run cmd = [{0}] on localhost".format(cmd)) - cmd = "bash -c '{0}'".format(cmd) - out = subprocess.Popen(cmd, stderr=subprocess.STDOUT, stdout=subprocess.PIPE, shell=True) + out = subprocess.Popen(cmd, stderr=subprocess.STDOUT, stdout=subprocess.PIPE, shell=True, executable='/bin/bash') stdout, stderr = out.communicate() return stderr except: @@ -351,7 +349,6 @@ def get_observer_version_by_sql(ob_cluster, stdio=None): ob_version_info = ob_connector.execute_sql("select version();") except Exception as e: raise Exception("get_observer_version_by_sql Exception. Maybe cluster'info is error: " + e.__str__()) - ob_version = ob_version_info[0] stdio.verbose("get_observer_version_by_sql ob_version_info is {0}".format(ob_version)) version = re.findall(r'OceanBase(_)?(.CE)?-v(.+)', ob_version[0]) diff --git a/common/ssh_client/local_client.py b/common/ssh_client/local_client.py index 1b5e932f..52ee2ca9 100644 --- a/common/ssh_client/local_client.py +++ b/common/ssh_client/local_client.py @@ -28,8 +28,7 @@ def __init__(self, context=None, node=None): def exec_cmd(self, cmd): try: self.stdio.verbose("[local host] run cmd = [{0}] on localhost".format(cmd)) - cmd = "bash -c '{0}'".format(cmd) - out = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + out = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, executable='/bin/bash') stdout, stderr = out.communicate() if stderr: return stderr.decode('utf-8') @@ -56,8 +55,7 @@ def ssh_invoke_shell_switch_user(self, new_user, cmd, time_out): try: cmd = "su - {0} -c '{1}'".format(new_user, cmd) self.stdio.verbose("[local host] ssh_invoke_shell_switch_user cmd = [{0}] on localhost".format(cmd)) - cmd = "bash -c '{0}'".format(cmd) - out = subprocess.Popen(cmd, stderr=subprocess.STDOUT, stdout=subprocess.PIPE, shell=True) + out = subprocess.Popen(cmd, stderr=subprocess.STDOUT, stdout=subprocess.PIPE, shell=True, executable='/bin/bash') stdout, stderr = out.communicate() if stderr: return stderr.decode('utf-8') diff --git a/handler/checker/result/verify.py b/handler/checker/result/verify.py index d4cb9f5f..06dde6b0 100644 --- a/handler/checker/result/verify.py +++ b/handler/checker/result/verify.py @@ -74,8 +74,7 @@ def _verify_base(self): else: real_shell = env + '="' + str(self.env_dict[env]) + '"\n' + real_shell self.stdio.verbose("real_shell: {0}".format(real_shell)) - real_shell = "bash -c '{0}'".format(real_shell) - process = subprocess.Popen(real_shell, shell=True, stdout=subprocess.PIPE) + process = subprocess.Popen(real_shell, shell=True, stdout=subprocess.PIPE, executable='/bin/bash') out, err = process.communicate() process.stdout.close() result = out[:-1].decode('utf-8')