rest-cmd is an open-source RESTful API server built in Go, enabling users to execute Linux commands via HTTP requests. It processes commands, captures their output, and returns the results in JSON format, making it easy to integrate Linux command execution in other applications or workflows.
- Execute Linux commands through RESTful API endpoints.
- Receive JSON-formatted responses with command output and error messages.
- Simple setup and usage via Makefile.
-
Clone the repository:
git clone https://github.com/esperar/rest-cmd.git cd rest-lic
-
Build and run using Make:
make run
This command will start the server on port
8080
by default.
Once the server is running, you can execute Linux commands via HTTP POST requests to the /exec
endpoint.
curl -X POST http://localhost:8080/exec -d '{"command": "ls -l"}' -H "Content-Type: application/json"
{
"output": "total 4\n-rw-r--r-- 1 user group 0 Oct 1 12:34 file.txt\n",
"error": ""
}
output
: Standard output of the command.error
: Error message, if any.
- Customize server settings by modifying environment variables or config files (details can be added here as your project evolves).
Feel free to fork this repository, create issues, or submit pull requests! For major changes, please open an issue first to discuss your ideas.
Please design the REST API rules as /{OS}/{cmd}! The directories should also follow the same structure: /{OS}/{cmd}. Additionally, please add the relevant endpoints to the README.
Distributed under the MIT License. See LICENSE
for more information.
We welcome contributions of commands from various OS environments!