如何在 node-red node exec 中运行命令来为 LCD 启用脚本 [英] How to run a command in node-red node exec to enable a script for LCD

查看:98
本文介绍了如何在 node-red node exec 中运行命令来为 LCD 启用脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个脚本可以在 Raspberry PI 的 LCD 上显示当前时间.

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

LCD 连接树莓派测试正常.

LCD is connected with Raspberry PI tested working fine.

我在 ~/.node-red 文件夹中创建了一个脚本名称 index.js,并使用以下命令在同一个 ~/.node-red 文件夹中安装了 LCD 节点模块:npm install lcd --save

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

当我使用命令在内部进行测试时,它会在 LCD 上显示时间.

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

如何在 node-red node exec 中执行这个 index.js 脚本?

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

我试过了,但没有用.

节点红色连接图

节点执行配置图片

在注入节点中,我输入了字符串 1 作为有效负载

In inject node I entered string 1 as payload

在 exec 节点我输入命令:sudo/home/pi/.node-red/node index.js

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.

先谢谢了

推荐答案

在 exec config 节点中

In the exec config node

  • 将命令更改为 /usr/bin/sudo
  • 取消选中附加 message.payload盒子
  • 将以下内容放在额外的输入参数中:node/home/pi/.node-red/index.js

您不需要将 index.js 放在 .node-red 目录中,但既然它在那里,这应该可以工作.

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

这篇关于如何在 node-red node exec 中运行命令来为 LCD 启用脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆