aboutsummaryrefslogtreecommitdiffstats
path: root/dgbuilder/core_nodes/core/75-exec.html
blob: 567a34c1990fedc041230cb14e8ee53ab7c3d36b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<!--
  Copyright 2013 IBM Corp.

  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at

  http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
-->

<script type="text/x-red" data-template-name="exec">
    <div class="form-row">
        <label for="node-input-command"><i class="fa fa-file"></i> Command</label>
        <input type="text" id="node-input-command" placeholder="command">
    </div>
    <div class="form-row">
        <label for="node-input-append"><i class="fa fa-list"></i> Append</label>
        <input type="text" id="node-input-append" placeholder="extra input">
    </div>
    <div class="form-row">
        <label>&nbsp;</label>
        <input type="checkbox" id="node-input-useSpawn" placeholder="spawn" style="display: inline-block; width: auto; vertical-align: top;">
        <label for="node-input-useSpawn" style="width: 70%;">Use spawn() instead of exec() ?</label>
    </div>
    <div class="form-row">
        <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
        <input type="text" id="node-input-name" placeholder="Name">
    </div>
    <div class="form-tips">Tip: <i>spawn</i> expects only one command word - and appended args to be comma separated.</div>
</script>

<script type="text/x-red" data-help-name="exec">
    <p>Calls out to a system command.<br/></p>
    <p>Provides 3 outputs... stdout, stderr, and return code.</p>
    <p>By default uses exec() which calls the command, blocks while waiting for completion, and then returns the complete result in one go, along with any errors.</p>
    <p>Optionally can use spawn() instead, which returns output from stdout and stderr as the command runs (ie one line at a time). On completion it then returns a return code (on the 3rd output).</p>
    <p>Spawn only expect one command word, with all extra parameters to be comma separated and passed as the append.</p>
    <p>The optional append gets added to the command after the <b>msg.payload</b> - so you can do things like pipe the result to another command.</p>
</script>

<script type="text/javascript">
    RED.nodes.registerType('exec',{
        category: 'advanced-function',
        color:"darksalmon",
        defaults: {
            command: {value:"",required:true},
            append: {value:""},
            useSpawn: {value:""},
            name: {value:""}
        },
        inputs:1,
        outputs:3,
        icon: "arrow-in.png",
        align: "right",
        label: function() {
            return this.name||this.command;
        },
        labelStyle: function() {
            return this.name?"node_label_italic":"";
        }
    });
</script>