mirror of
https://github.com/Ylianst/MeshCentral.git
synced 2025-04-25 04:33:16 -04:00
runcommands now shows live output in console instead of after finishing #6948
Signed-off-by: si458 <simonsmith5521@gmail.com>
This commit is contained in:
parent
5f68458cc5
commit
440cad5b50
@ -1556,14 +1556,13 @@ function handleServerCommand(data) {
|
|||||||
// Windows command shell
|
// Windows command shell
|
||||||
mesh.cmdchild = require('child_process').execFile(process.env['windir'] + '\\system32\\cmd.exe', ['cmd'], options);
|
mesh.cmdchild = require('child_process').execFile(process.env['windir'] + '\\system32\\cmd.exe', ['cmd'], options);
|
||||||
mesh.cmdchild.descriptorMetadata = 'UserCommandsShell';
|
mesh.cmdchild.descriptorMetadata = 'UserCommandsShell';
|
||||||
mesh.cmdchild.stdout.on('data', function (c) { replydata += c.toString(); });
|
mesh.cmdchild.stdout.on('data', function (c) { replydata += c.toString(); sendConsoleText(c.toString()); });
|
||||||
mesh.cmdchild.stderr.on('data', function (c) { replydata += c.toString(); });
|
mesh.cmdchild.stderr.on('data', function (c) { replydata += c.toString(); sendConsoleText(c.toString()); });
|
||||||
mesh.cmdchild.stdin.write(data.cmds + '\r\nexit\r\n');
|
mesh.cmdchild.stdin.write(data.cmds + '\r\nexit\r\n');
|
||||||
mesh.cmdchild.on('exit', function () {
|
mesh.cmdchild.on('exit', function () {
|
||||||
if (data.reply) {
|
if (data.reply) {
|
||||||
mesh.SendCommand({ action: 'msg', type: 'runcommands', result: replydata, sessionid: data.sessionid, responseid: data.responseid });
|
mesh.SendCommand({ action: 'msg', type: 'runcommands', result: replydata, sessionid: data.sessionid, responseid: data.responseid });
|
||||||
} else {
|
} else {
|
||||||
sendConsoleText(replydata);
|
|
||||||
sendConsoleText("Run commands completed.");
|
sendConsoleText("Run commands completed.");
|
||||||
}
|
}
|
||||||
delete mesh.cmdchild;
|
delete mesh.cmdchild;
|
||||||
@ -1572,14 +1571,13 @@ function handleServerCommand(data) {
|
|||||||
// Windows Powershell
|
// Windows Powershell
|
||||||
mesh.cmdchild = require('child_process').execFile(process.env['windir'] + '\\System32\\WindowsPowerShell\\v1.0\\powershell.exe', ['powershell', '-noprofile', '-nologo', '-command', '-'], options);
|
mesh.cmdchild = require('child_process').execFile(process.env['windir'] + '\\System32\\WindowsPowerShell\\v1.0\\powershell.exe', ['powershell', '-noprofile', '-nologo', '-command', '-'], options);
|
||||||
mesh.cmdchild.descriptorMetadata = 'UserCommandsPowerShell';
|
mesh.cmdchild.descriptorMetadata = 'UserCommandsPowerShell';
|
||||||
mesh.cmdchild.stdout.on('data', function (c) { replydata += c.toString(); });
|
mesh.cmdchild.stdout.on('data', function (c) { replydata += c.toString(); sendConsoleText(c.toString()); });
|
||||||
mesh.cmdchild.stderr.on('data', function (c) { replydata += c.toString(); });
|
mesh.cmdchild.stderr.on('data', function (c) { replydata += c.toString(); sendConsoleText(c.toString()); });
|
||||||
mesh.cmdchild.stdin.write(data.cmds + '\r\nexit\r\n');
|
mesh.cmdchild.stdin.write(data.cmds + '\r\nexit\r\n');
|
||||||
mesh.cmdchild.on('exit', function () {
|
mesh.cmdchild.on('exit', function () {
|
||||||
if (data.reply) {
|
if (data.reply) {
|
||||||
mesh.SendCommand({ action: 'msg', type: 'runcommands', result: replydata, sessionid: data.sessionid, responseid: data.responseid });
|
mesh.SendCommand({ action: 'msg', type: 'runcommands', result: replydata, sessionid: data.sessionid, responseid: data.responseid });
|
||||||
} else {
|
} else {
|
||||||
sendConsoleText(replydata);
|
|
||||||
sendConsoleText("Run commands completed.");
|
sendConsoleText("Run commands completed.");
|
||||||
}
|
}
|
||||||
delete mesh.cmdchild;
|
delete mesh.cmdchild;
|
||||||
@ -1589,14 +1587,13 @@ function handleServerCommand(data) {
|
|||||||
// Linux shell
|
// Linux shell
|
||||||
mesh.cmdchild = require('child_process').execFile('/bin/sh', ['sh'], options);
|
mesh.cmdchild = require('child_process').execFile('/bin/sh', ['sh'], options);
|
||||||
mesh.cmdchild.descriptorMetadata = 'UserCommandsShell';
|
mesh.cmdchild.descriptorMetadata = 'UserCommandsShell';
|
||||||
mesh.cmdchild.stdout.on('data', function (c) { replydata += c.toString(); });
|
mesh.cmdchild.stdout.on('data', function (c) { replydata += c.toString(); sendConsoleText(c.toString()); });
|
||||||
mesh.cmdchild.stderr.on('data', function (c) { replydata += c.toString(); });
|
mesh.cmdchild.stderr.on('data', function (c) { replydata += c.toString(); sendConsoleText(c.toString()); });
|
||||||
mesh.cmdchild.stdin.write(data.cmds.split('\r').join('') + '\nexit\n');
|
mesh.cmdchild.stdin.write(data.cmds.split('\r').join('') + '\nexit\n');
|
||||||
mesh.cmdchild.on('exit', function () {
|
mesh.cmdchild.on('exit', function () {
|
||||||
if (data.reply) {
|
if (data.reply) {
|
||||||
mesh.SendCommand({ action: 'msg', type: 'runcommands', result: replydata, sessionid: data.sessionid, responseid: data.responseid });
|
mesh.SendCommand({ action: 'msg', type: 'runcommands', result: replydata, sessionid: data.sessionid, responseid: data.responseid });
|
||||||
} else {
|
} else {
|
||||||
sendConsoleText(replydata);
|
|
||||||
sendConsoleText("Run commands completed.");
|
sendConsoleText("Run commands completed.");
|
||||||
}
|
}
|
||||||
delete mesh.cmdchild;
|
delete mesh.cmdchild;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user