Skip to content

Provide the cmd OS(Linux, MacOS, Windows) in a RESTful

License

Notifications You must be signed in to change notification settings

esperar/rest-cmd

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

rest-cmd

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.

vmstat.png

Features

  • Execute Linux commands through RESTful API endpoints.
  • Receive JSON-formatted responses with command output and error messages.
  • Simple setup and usage via Makefile.

Installation

  1. Clone the repository:

    git clone https://github.com/esperar/rest-cmd.git
    cd rest-lic
  2. Build and run using Make:

    make run

    This command will start the server on port 8080 by default.

Usage

Once the server is running, you can execute Linux commands via HTTP POST requests to the /exec endpoint.

Example Request

curl -X POST http://localhost:8080/exec -d '{"command": "ls -l"}' -H "Content-Type: application/json"

Example Response

{
  "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.

Configuration

  • Customize server settings by modifying environment variables or config files (details can be added here as your project evolves).

Contribution

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.

License

Distributed under the MIT License. See LICENSE for more information.

We welcome contributions of commands from various OS environments!

About

Provide the cmd OS(Linux, MacOS, Windows) in a RESTful

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published