Spaces:
Paused
Paused
File size: 808 Bytes
21fe7c2 584a875 21fe7c2 4026a06 584a875 21fe7c2 584a875 4026a06 584a875 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
import gradio as gr
import subprocess
def run_command(command):
try:
# Run the command and capture the output
result = subprocess.run(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
# Return the output or any error encountered
if result.returncode == 0:
return f"Output:\n{result.stdout}"
else:
return f"Error:\n{result.stderr}"
except Exception as e:
return str(e)
# Create a Gradio interface
iface = gr.Interface(fn=run_command,
inputs="text",
outputs="text",
title="Linux Command Runner",
description="Enter a Linux command to execute and see the output.")
# Launch the interface
iface.launch()
|