I have Greengrass edge machine (which is Ubuntu machine basically).
I open its terminal and run sudo /greengrass/v2/bin/greengrass-cli component list
and it return me desire result.
I have Nodejs app and from Nodejs app, I want to execute the same command. The node code looks as below,
greengrass.controller.js
const execSync = require("child_process").execSync;
const listcmd = execSync("sudo /greengrass/v2/bin/greengrass-cli component list", {
stdio: "inherit",
shell: "/bin/bash"
});
- After writing above code, I create docker image and container of node app.
- I run AWS greengrass IOT core pipeline and deploy this container to edge machine (to same ubuntu machine)
- I execute my deployed node app on the edge machine and it throws error that failed to execute command but while executing the same command in the terminal, works fine.
Que: What is wrong with it? What should be the root cause of it ?
1