import subprocess
def get_command_output(command):
try:
# Execute the command and capture the output
output = subprocess.check_output(command, shell=True, stderr=subprocess.STDOUT)
# Decode the output (assuming it's encoded in UTF-8)
decoded_output = output.decode('utf-8')
# Return the decoded output
return decoded_output
except subprocess.CalledProcessError as e:
# Handle any errors that occurred during command execution
print(f"Error executing command: {e}")
return None
# Example usage:
output = get_command_output('ls -l')
print(output)