From 08b11addecbfb0da7b3e0efce7ae0c87987cc981 Mon Sep 17 00:00:00 2001 From: Dave Conway-Jones Date: Fri, 6 Jan 2017 09:55:52 +0000 Subject: [PATCH] Let exec node (spawn) handle commands with spaces in path --- nodes/core/core/75-exec.html | 2 +- nodes/core/core/75-exec.js | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/nodes/core/core/75-exec.html b/nodes/core/core/75-exec.html index a6c7fe339..f354db965 100644 --- a/nodes/core/core/75-exec.html +++ b/nodes/core/core/75-exec.html @@ -53,7 +53,7 @@ (on the 3rd output).

The optional append gets added to the command after msg.payload - so you can do things like pipe the result to another command.

-

Parameters with spaces should be enclosed in quotes - "This is a single parameter"

+

Commands or parameters with spaces should be enclosed in quotes - "This is a single parameter"

If stdout is binary a buffer is returned - otherwise returns a string.

The blue status icon will be visible while the node is active.

If running a Python app you may need to use the -u parameter to stop the output being buffered.

diff --git a/nodes/core/core/75-exec.js b/nodes/core/core/75-exec.js index f4caa7e5b..931dbb616 100644 --- a/nodes/core/core/75-exec.js +++ b/nodes/core/core/75-exec.js @@ -49,6 +49,7 @@ module.exports = function(RED) { // slice whole line by spaces (trying to honour quotes); arg = arg.match(/(?:[^\s"]+|"[^"]*")+/g); var cmd = arg.shift(); + if (/^".*"$/.test(cmd)) { cmd = cmd.slice(1,-1); } /* istanbul ignore else */ if (RED.settings.verbose) { node.log(cmd+" ["+arg+"]"); } child = spawn(cmd,arg);