fix shell_exec issue

This commit is contained in:
Alessandro ZANNI 2016-07-29 22:42:06 +02:00
parent 5973a8d432
commit 895bfae82d
1 changed files with 2 additions and 4 deletions

View File

@ -6,8 +6,6 @@ import subprocess
def shell_exec(client, cmdline, shell=None): def shell_exec(client, cmdline, shell=None):
""" cmdline can be either a list of arguments or a string """ """ cmdline can be either a list of arguments or a string """
if type(cmdline) is not list:
cmdline=cmdline.split()
res="" res=""
try: try:
if client.is_android(): if client.is_android():
@ -17,9 +15,9 @@ def shell_exec(client, cmdline, shell=None):
res=client.conn.modules.subprocess.check_output(cmdline, stderr=subprocess.STDOUT, stdin=subprocess.PIPE, shell=True, universal_newlines=True) res=client.conn.modules.subprocess.check_output(cmdline, stderr=subprocess.STDOUT, stdin=subprocess.PIPE, shell=True, universal_newlines=True)
else: else:
if client.is_windows(): if client.is_windows():
command=[shell, '/c'] + cmdline command=[shell, '/c', cmdline]
else: else:
command=[shell, '-c'] + cmdline command=[shell, '-c', cmdline]
res=client.conn.modules.subprocess.check_output(command, stderr=subprocess.STDOUT, stdin=subprocess.PIPE, universal_newlines=True) res=client.conn.modules.subprocess.check_output(command, stderr=subprocess.STDOUT, stdin=subprocess.PIPE, universal_newlines=True)
except Exception as e: except Exception as e:
if hasattr(e,'output') and e.output: if hasattr(e,'output') and e.output: