fix odl patches
[ccsdk/distribution.git] / dgbuilder / core_nodes / core / 75-exec.html
1 <!--
2   Copyright 2013 IBM Corp.
3
4   Licensed under the Apache License, Version 2.0 (the "License");
5   you may not use this file except in compliance with the License.
6   You may obtain a copy of the License at
7
8   http://www.apache.org/licenses/LICENSE-2.0
9
10   Unless required by applicable law or agreed to in writing, software
11   distributed under the License is distributed on an "AS IS" BASIS,
12   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   See the License for the specific language governing permissions and
14   limitations under the License.
15 -->
16
17 <script type="text/x-red" data-template-name="exec">
18     <div class="form-row">
19         <label for="node-input-command"><i class="fa fa-file"></i> Command</label>
20         <input type="text" id="node-input-command" placeholder="command">
21     </div>
22     <div class="form-row">
23         <label for="node-input-append"><i class="fa fa-list"></i> Append</label>
24         <input type="text" id="node-input-append" placeholder="extra input">
25     </div>
26     <div class="form-row">
27         <label>&nbsp;</label>
28         <input type="checkbox" id="node-input-useSpawn" placeholder="spawn" style="display: inline-block; width: auto; vertical-align: top;">
29         <label for="node-input-useSpawn" style="width: 70%;">Use spawn() instead of exec() ?</label>
30     </div>
31     <div class="form-row">
32         <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
33         <input type="text" id="node-input-name" placeholder="Name">
34     </div>
35     <div class="form-tips">Tip: <i>spawn</i> expects only one command word - and appended args to be comma separated.</div>
36 </script>
37
38 <script type="text/x-red" data-help-name="exec">
39     <p>Calls out to a system command.<br/></p>
40     <p>Provides 3 outputs... stdout, stderr, and return code.</p>
41     <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>
42     <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>
43     <p>Spawn only expect one command word, with all extra parameters to be comma separated and passed as the append.</p>
44     <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>
45 </script>
46
47 <script type="text/javascript">
48     RED.nodes.registerType('exec',{
49         category: 'advanced-function',
50         color:"darksalmon",
51         defaults: {
52             command: {value:"",required:true},
53             append: {value:""},
54             useSpawn: {value:""},
55             name: {value:""}
56         },
57         inputs:1,
58         outputs:3,
59         icon: "arrow-in.png",
60         align: "right",
61         label: function() {
62             return this.name||this.command;
63         },
64         labelStyle: function() {
65             return this.name?"node_label_italic":"";
66         }
67     });
68 </script>