How to run a command in node-red node exec to enable a script for LCD

∥☆過路亽.° 提交于 2020-01-04 06:50:23

问题


I have a script to bring a current time on LCD in Raspberry PI.

LCD is connected with Raspberry PI tested working fine.

I created a script name index.js inside ~/.node-red folder, and have installed LCD node module inside the same ~/.node-red folder using command : npm install lcd --save

cd ~/.node-red
pi@raspberrypi ~/.node-red $ sudo node index.js

When I tested inside using the command it brings the time on the LCD.

How to execute this index.js script in node-red node exec?

I have tried but does not work.

node-red connection picture

node exec config picture

In inject node I entered string 1 as payload

In exec node I entered command: sudo /home/pi/.node-red/node index.js

I tried in many ways to execute but no luck,

please check the pictures and help me in this issue.

Thanks a lot in advance


回答1:


In the exec config node

  • Change the command to just /usr/bin/sudo
  • Uncheck the append message.payload box
  • Place the following in the extra input parameters: node /home/pi/.node-red/index.js

You don't need to put your index.js in the .node-red directory but since it's there this should work.



来源:https://stackoverflow.com/questions/33222875/how-to-run-a-command-in-node-red-node-exec-to-enable-a-script-for-lcd

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!