Skip to content
Snippets Groups Projects
Commit 62e4e1ce authored by Antoine Millet's avatar Antoine Millet
Browse files

Added stdin argument to execute_command

parent 415a9189
No related branches found
No related tags found
No related merge requests found
......@@ -278,16 +278,18 @@ class Handler(BasePlugin):
logger.debug('Plugins state saved')
@rpc_handler
def execute_command(self, command):
def execute_command(self, command, stdin=None):
"""Execute an arbitrary shell command on the host.
:param string command: shell command to run
:param string stdin: string to use as stdin on command
"""
logger.debug('Executing command %s', command)
try:
remote_command = EvPopen(self.main, command, close_fds=True,
shell=True, stdout=PIPE, stderr=STDOUT)
shell=True, stdout=PIPE, stdin=PIPE,
stderr=STDOUT)
except Exception:
logger.exception('Error while starting subprocess for executing '
' command %s', command)
......@@ -296,7 +298,7 @@ class Handler(BasePlugin):
self.commands.add(remote_command)
try:
stdout, _ = remote_command.communicate()
stdout, _ = remote_command.communicate(stdin)
except Exception:
logger.exception('Error while communicating with subprocess for'
' command %s', command)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment