Calling linux commandline functions from NODE.JS

Nov 12, 2016 Dev, Internet of Things

Calling linux commandline functions from NODE.JS

[Reading Time: < 1 minute]

[sgmb id=”1″]Currently I’am working on a project, where device management (dm) is needed. So a part of dm is to control devices remotely. My setup is a linux based device, that is connected to Azure Clouds IoT Hub with the new DeviceManagement-Feature. That device is controled by a NodeJs-App. One task of that is, to handle a reboot signal from the cloud. The problem I had, was to break through the node.js environment and to convince the device, to reboot. After some try-outs, I came up with following simple solution – maybe someone has the same problem, than this is a good start:

1) npm install sys child_process

2) …and use it as follows:

var sys = require('sys')
var exec = require('child_process').exec;
function puts(error, stdout, stderr) {
  sys.puts(stdout)
};
exec("reboot");

cheers!

By Thomas Tomow

As a Managing Consultant, I am working at Alegri in Stuttgart/Germany. There I keep focusing with a team specialized in IoT, UX/Design and DevOps on preparing customers for the next digital future. I have been working as IT Consultant, IT Architect and lead developer with skills in .NetFramework, agile methodologies like Scrum and much more for nearly 2 decades. In the last few years I started focusing in IoT & Digitalization strategies in enterprise scenarios. Manly I used Microsofts Azure Cloud, to support customers in letting their visions become true. Sharing knowledge and practicing principles is something, that I like very much. Therefore I am also Co-Administrator of Azure-Meetup group in Stuttgart, where I'd also like to share my experiences. With this I was awarded in november by Microsoft as a MVP (Most Valuable Professional).

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.