Last active
December 14, 2020 15:36
-
-
Save uphy/7aab9758be41888e20b94d14e9c50976 to your computer and use it in GitHub Desktop.
Node-RED Execute multiline shell script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[{"id":"1a73c740.e06d79","type":"subflow","name":"Execute Shell Script","info":"","in":[{"x":100,"y":200,"wires":[{"id":"662c3c62.43d624"}]}],"out":[{"x":960,"y":280,"wires":[{"id":"9e92978.d8d0868","port":0}]},{"x":960,"y":340,"wires":[{"id":"9e92978.d8d0868","port":1}]},{"x":960,"y":400,"wires":[{"id":"9e92978.d8d0868","port":2}]}]},{"id":"dda86e6b.3b362","type":"file","z":"1a73c740.e06d79","name":"Write script file","filename":"","appendNewline":true,"createDir":false,"overwriteFile":"false","x":860,"y":140,"wires":[]},{"id":"7a2a96f.a52b268","type":"exec","z":"1a73c740.e06d79","command":"mktemp","addpay":false,"append":"","useSpawn":"","timer":"","name":"","x":420,"y":200,"wires":[["9131a546.667eb8"],[],[]]},{"id":"c9fb5364.0becc","type":"file","z":"1a73c740.e06d79","name":"Delete script file","filename":"","appendNewline":true,"createDir":false,"overwriteFile":"delete","x":1020,"y":480,"wires":[]},{"id":"9e92978.d8d0868","type":"exec","z":"1a73c740.e06d79","command":" sh ","addpay":true,"append":"","useSpawn":"","timer":"","name":"Execute the shell script","x":690,"y":340,"wires":[["c9fb5364.0becc"],[],[]]},{"id":"36f470a4.a6a84","type":"exec","z":"1a73c740.e06d79","command":"chmod +x ","addpay":true,"append":"","useSpawn":"","timer":"","name":"","x":1040,"y":200,"wires":[["6ba1dbc1.d547b4"],[],[]]},{"id":"662c3c62.43d624","type":"change","z":"1a73c740.e06d79","name":"","rules":[{"t":"set","p":"command","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":230,"y":200,"wires":[["7a2a96f.a52b268"]]},{"id":"a61c48a5.e5dc88","type":"change","z":"1a73c740.e06d79","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"filename","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":860,"y":200,"wires":[["36f470a4.a6a84"]]},{"id":"9131a546.667eb8","type":"function","z":"1a73c740.e06d79","name":"","func":"msg.filename = msg.payload.trim();\nmsg.payload = msg.command;\nreturn msg;","outputs":1,"noerr":0,"x":590,"y":180,"wires":[["dda86e6b.3b362","a61c48a5.e5dc88"]]},{"id":"6ba1dbc1.d547b4","type":"change","z":"1a73c740.e06d79","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"filename","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":480,"y":340,"wires":[["9e92978.d8d0868"]]},{"id":"f21f0fb8.12361","type":"comment","z":"1a73c740.e06d79","name":"Execute shell script","info":"Execute the shell script in msg.payload.","x":130,"y":40,"wires":[]},{"id":"743f5337.595bcc","type":"inject","z":"25a6867.0cf2d7a","name":"Start","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"x":170,"y":80,"wires":[["92fd8149.b5867"]]},{"id":"92fd8149.b5867","type":"template","z":"25a6867.0cf2d7a","name":"Shell Script","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"#! /bin/sh\n\necho Timestamp is {{payload}}.","x":330,"y":80,"wires":[["5b242947.2d4ac8"]]},{"id":"5b242947.2d4ac8","type":"subflow:1a73c740.e06d79","z":"25a6867.0cf2d7a","x":530,"y":80,"wires":[["24c6f0cd.3edaa"],["24c6f0cd.3edaa"],["24c6f0cd.3edaa"]]},{"id":"24c6f0cd.3edaa","type":"debug","z":"25a6867.0cf2d7a","name":"Log the result","active":true,"console":"false","complete":"payload","x":740,"y":80,"wires":[]}] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment