1.2.4 • Published 11 months ago

zion-cmd-server v1.2.4

Weekly downloads
-
License
-
Repository
-
Last release
11 months ago

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
});
1.2.4

11 months ago

1.2.3

11 months ago

1.2.2

1 year ago

1.2.1

1 year ago

1.1.1

2 years ago

1.1.0

2 years ago

1.0.2

2 years ago

1.0.9

2 years ago

1.0.8

2 years ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago