Giter Club home page Giter Club logo

wsterm's Introduction

Websocket Terminal

    Run commands through websocket

Requirements

    golang - compile the code
    expect - handle processes
    bash   - run the command

Installation

    go get -u -v github.com/jiangmiao/wsterm/wsterm

Usage

    $ wsterm
    2018/03/11 19:39:28 websocket url ws://localhost:9300/ws

    # use https://github.com/hashrocket/ws send test requests
    # general echo
    $ ws ws://localhost:9300/ws
    > {"type":"exec", "data":"echo hello world"}
    < {"type":"stdout","data":"hello world\r\n"}
    < {"type":"exit","data":{"code":0,"message":""}}

    # stderr handle
    $ ws ws://localhost:9300/ws
    > {"type":"exec","data":"curl"}
    < {"type":"stderr","data":"curl: try 'curl -"}
    < {"type":"stderr","data":"-help' or 'curl --manual' for more information\n"}
    < {"type":"exit","data":{"code":2,"message":"exit status 2"}}

    # stop process
    $ ws ws://localhost:9300/ws
    > {"type":"exec", "data":"sudo ping 127.0.0.1"}
    < {"type":"stdout","data":"PING 127.0.0.1 (127.0.0.1) 56(84) bytes of data.\r\n64 bytes from 127.0.0.1: icmp_seq=1 ttl=64 time=0.038 ms\r\n"}
    < {"type":"stdout","data":"64 bytes from 127.0.0.1: icmp_seq=2 ttl=64 time=0.044 ms\r\n"}
    < {"type":"stdout","data":"64 bytes from 127.0.0.1: icmp_seq=3 ttl=64 time=0.043 ms\r\n"}
    # send stop message
    > {"type":"stop"}
    < {"type":"exit","data":{"code":130,"message":"exit status 130"}}

Request Messages

    {"type": "exec", "data": "command"}
    {"type": "stop"}

Response Messages

    {"type": "stdout", "data": "stdout text"}
    {"type": "stderr", "data": "stderr text"}
    {"type": "exit",   "data": {"code": 0, "message", "error message"}}

License

    MIT

wsterm's People

Contributors

jiangmiao avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

portalgun-io

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.