节点执行者无权执行脚本

编程入门 行业动态 更新时间:2024-10-12 03:17:43
本文介绍了节点执行者无权执行脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

直到最近,它仍然可以正常工作,但是当我今天尝试使用它时,它无法正常工作.它返回以下错误:

Up until recently, it has worked fine, but when I tried to use it today, it did not work properly. It returns the following error:

错误:命令失败:/bin/sh -c/home/pi/RPi-Computer-Power/RPi-Server/routes/../scripts/hash.js12345678/bin/sh:1:/home/pi/RPi-Computer-Power/RPi-Server/routes/../scripts/hash.js:权限被拒绝

Error: Command failed: /bin/sh -c /home/pi/RPi-Computer-Power/RPi-Server/routes/../scripts/hash.js 12345678 /bin/sh: 1: /home/pi/RPi-Computer-Power/RPi-Server/routes/../scripts/hash.js: Permission denied

我非常困惑,因为当我尝试从命令行运行脚本时,它可以完美运行;/home/pi/RPi-Computer-Power/RPi-Server/routes/../scripts/hash.js 12345 完美执行.

I am extremely confused because when I try to run the script from the command line, it works perfectly; /home/pi/RPi-Computer-Power/RPi-Server/routes/../scripts/hash.js 12345 executes flawlessly.

这是我尝试执行脚本的代码.(index.js)

This is the code where I try to execute the script. (index.js)

exec(__dirname+"/../scripts/"+req.params.script+" "+req.body.params, function(err, stdout, stderr) { console.log("err: ",err,"stdout: ",stdout,"stderr: ",stderr); if(err){ res.send("<a href='/'>< Back</a> <b>Program Error:</b> "+err.toString()); return; } //res.send("<a href='/'>< Back</a> <b>Program Output:</b> <div style='white-space:pre-line>'"+stdout+stderr+"</div>"); res.render("programOutput", {output: stdout}); });

如果有任何帮助,请提前谢谢.尼尔

If anyone has any help, thank you in advance. Neil

推荐答案

我想到两件事:

1)确保您要执行的脚本是可执行的,例如: chmod + x/folder/script

1) Make sure that the script you are trying to execute is executable ex: chmod +x /folder/script

2)在许多 Linux 发行版中,默认的终端外壳是 bash .您显示的错误包括使用/bin/sh -c ,在许多 Linux 发行版中,默认设置为 dash (是的,不同的默认 shell 用于终端,以及用于在没有终端的情况下运行脚本的代码).因此,由于它似乎可以在 bash 中使用,请尝试使用 bash -c/folder/script 调用脚本.

2) The default terminal shell on many Linux distributions is bash. The error you displayed includes using /bin/sh -c, which would default in many Linux distributions to dash (yes, a different default shell for the terminal and for running scripts without the terminal). Thus, since it seems to work in bash, try to evoke the script with bash -c /folder/script.

更多推荐

节点执行者无权执行脚本

本文发布于:2023-11-25 13:08:22,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1629879.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:执行者   节点   脚本

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!