import subprocess import gradio as gr def infer(command): status = "Success" result = None try: result = subprocess.check_output( command, shell=True, stderr=subprocess.STDOUT, text=True, ) except Exception as e: status = f"Error: {e.output}" return status, result if __name__ == "__main__": gr.Interface( fn=infer, inputs=gr.Textbox(label="Linux Command", value="ls"), outputs=[ gr.Textbox(label="Status", show_copy_button=True), gr.TextArea(label="Command Output", show_copy_button=True), ], title="Linux Command Executor", description="Enter a Linux command and click submit to see the output.", flagging_mode="never", ).launch(ssr_mode=False)