Learn how to use the WebShell API to execute commands programmatically.
The WebShell API allows you to execute Fedora commands programmatically through HTTP POST requests. This API is designed to interact with a web-based Fedora terminal, enabling you to run commands and retrieve their output in a structured format.
https://web-terminal-eight.vercel.app
Endpoint: /run
Method: POST
Content-Type: application/json
This endpoint allows you to execute a Fedora command in the WebShell terminal. The command is provided as a JSON payload, and the API returns the output of the command.
URL:
https://web-terminal-eight.vercel.app/run
Headers:
Content-Type: application/json
Body:
{
"command": "your-command-here"
}
Replace "your-command-here"
with the actual command you wish to run.
To list files and directories in the current directory, you would use the following curl
command:
curl -X POST https://web-terminal-eight.vercel.app/run \
-H "Content-Type: application/json" \
-d '{"command": "ls -l"}'
The response will be a JSON object with the following structure:
{
"stdout": "command output here",
"stderr": "error output here",
"exitCode": exit_code
}
stdout
: The standard output of the command.stderr
: The standard error output of the command (if any).exitCode
: The exit code of the command.For the command ls -l
, you might receive:
{
"stdout": "total 2\ndrwxr-xr-x 67 root root 1187 Jul 27 00:36 node_modules\n-rwxr-xr-x 1 root root 303 Oct 20 2018 package.json\n-rwxr-xr-x 1 root root 753 Oct 20 2018 server.js\n"
}
curl -X POST https://web-terminal-eight.vercel.app/run \
-H "Content-Type: application/json" \
-d '{"command": "ls -l"}'
curl -X POST https://web-terminal-eight.vercel.app/run \
-H "Content-Type: application/json" \
-d '{"command": "df -h"}'