import os def execute_cmd(cmd:str) -> str: """ Execute the command in the mac terminal. Parameters ---------- cmd: str The command to be executed. Returns ---------- output: str The output of the command. """ # execute the command in the mac terminal. # Alert!! The execution should be really careful, because it can be dangerous. # It is recommended to use this in a sandbox environment. try: output = os.popen(cmd).read() except Exception as e: print("Error when executing command %s in terminal:" % cmd ) print("Error is:", e) return False return output