Code Monkey home page Code Monkey logo

cmd-server's Introduction

Cmd-Server

Introduction

use http to execute cmd on your remote machine

Requirement

nodejs

Installation

npm install -g zion-cmd-server

server start / stop

sudo cmds # port: 7777 mac needs sudo

ctrl+c # end server 
sudo cmds --port 4396 # custom server port 
sudo cmds --passwd 123456 # custom password, you can add it in request method

client request

import axios from "axios";

const version = (await axios.request({
    url: `http://${ip}:7777/version`,
    method: 'get',
    timeout: 10e3,
    params: {
        passwd: '123456'
    }
})).data

const arch = (await axios.request({
    url: `http://${ip}:7777/arch`,
    method: 'get',
    timeout: 10e3,
    params: {
        passwd: '123456'
    }
})).data
console.log(arch); // arch = intel / arm

const os = (await axios.request({
    url: `http://${ip}:7777/os`,
    method: 'get',
    timeout: 10e3,
    params: {
        passwd: '123456'
    }
})).data
console.log(os); // os = win / mac / linux

const data = (await axios.request({
    url: `http://${ip}:7777/cmd`,
    method: 'post',
    timeout: 10e3,
    data: {
        cmd: `ls`,
        timeout: 10e3
    },
    params: {
        passwd: '123456'
    }
})).data;
console.log(data);

import * as FormData from "form-data";

const filePath = `/Users/xxxxx/xxxxx/xxxxx.zip`;
const fileName = path.basename(filePath);
const fileData = fs.readFileSync(filePath);
const formData = new FormData();
formData.append('file', fileData, fileName);
formData.append('dest', `$HOME/cmd-server`);
await AxiosUtil.request({
    url: `http://127.0.0.1:7777/file`,
    method: 'post',
    headers: { ...formData.getHeaders() },
    data: formData
});

cmd-server's People

Contributors

speaksugar avatar

Watchers

 avatar

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.