( self, cmd=None, # The command line to run raw=False, # Delimiters value=False, # Will use the output elsewhere? timeout=False, # Timeout expect_func=None, # Function that determines what to wait for in the response force_cmd=False, # Execute cmd command from powershell separate=False, # If true, send cmd via this method but receive with TLV method (agent) # --- Agent only args --- agent_typing=False, # Simulate typing on shell python=False, # Execute python command stdin_src=None, # stdin stream source stdout_dst=None, # stdout stream destination stderr_dst=None, # stderr stream destination stdin_stream=None, # stdin_stream object stdout_stream=None, # stdout_stream object stderr_stream=None, # stderr_stream object agent_control=None # control queue )
| 2721 | return True |
| 2722 | |
| 2723 | def exec( |
| 2724 | self, |
| 2725 | cmd=None, # The command line to run |
| 2726 | raw=False, # Delimiters |
| 2727 | value=False, # Will use the output elsewhere? |
| 2728 | timeout=False, # Timeout |
| 2729 | expect_func=None, # Function that determines what to wait for in the response |
| 2730 | force_cmd=False, # Execute cmd command from powershell |
| 2731 | separate=False, # If true, send cmd via this method but receive with TLV method (agent) |
| 2732 | # --- Agent only args --- |
| 2733 | agent_typing=False, # Simulate typing on shell |
| 2734 | python=False, # Execute python command |
| 2735 | stdin_src=None, # stdin stream source |
| 2736 | stdout_dst=None, # stdout stream destination |
| 2737 | stderr_dst=None, # stderr stream destination |
| 2738 | stdin_stream=None, # stdin_stream object |
| 2739 | stdout_stream=None, # stdout_stream object |
| 2740 | stderr_stream=None, # stderr_stream object |
| 2741 | agent_control=None # control queue |
| 2742 | ): |
| 2743 | if self.agent and not agent_typing: # TODO environment will not be the same as shell |
| 2744 | if cmd: |
| 2745 | cmd = dedent(cmd) |
| 2746 | if value: |
| 2747 | buffer = io.BytesIO() |
| 2748 | timeout = self.timeout_short if value else None |
| 2749 | |
| 2750 | if not stdin_stream: |
| 2751 | stdin_stream = self.new_streamID |
| 2752 | if not stdin_stream: |
| 2753 | return |
| 2754 | if not stdout_stream: |
| 2755 | stdout_stream = self.new_streamID |
| 2756 | if not stdout_stream: |
| 2757 | return |
| 2758 | if not stderr_stream: |
| 2759 | stderr_stream = self.new_streamID |
| 2760 | if not stderr_stream: |
| 2761 | return |
| 2762 | |
| 2763 | _type = 'S'.encode() if not python else 'P'.encode() |
| 2764 | self.send(Messenger.message( |
| 2765 | Messenger.EXEC, _type + |
| 2766 | stdin_stream.id + |
| 2767 | stdout_stream.id + |
| 2768 | stderr_stream.id + |
| 2769 | cmd.encode() |
| 2770 | )) |
| 2771 | logger.debug(cmd) |
| 2772 | #print(stdin_stream.id, stdout_stream.id, stderr_stream.id) |
| 2773 | |
| 2774 | rlist = [] |
| 2775 | if stdin_src: |
| 2776 | rlist.append(stdin_src) |
| 2777 | if stdout_dst or value: |
| 2778 | rlist.append(stdout_stream) |
| 2779 | if stderr_dst or value: |
| 2780 | rlist.append(stderr_stream) # FIX |
no test coverage detected