简体   繁体   English

popen:“ sh:权限被拒绝”

[英]popen: 'sh: permission denied"

I'm trying to use popen. 我正在尝试使用popen。 When I execute some system command (eg let's say ls or whatever) all works fine. 当我执行一些系统命令(例如ls之类的命令)时,一切正常。 But when I'm trying to execute my executable: 但是,当我尝试执行我的可执行文件时:

pipe = popen("./ <path>","r");

I get an error: sh: permission denied. 我收到一个错误:sh:权限被拒绝。

Both executables (which uses popen and that one which I want to launch from first one) belong to my user accound and have "x" permissions. 这两个可执行文件(使用popen以及我要从第一个启动的可执行文件)都属于我的用户帐户,并且具有“ x”权限。

I'd double check that error message, since it should say what the permission denied relates too. 我会仔细检查该错误消息,因为它也应该说明被拒绝的权限也与之相关。 ie if path was empty, and you just passed ./, or had an extra space like in your example, you should see 例如,如果路径为空,而您刚刚传递了./,或如示例中那样有多余的空间,则应该看到

sh: ./: Permission denied sh:./:权限被拒绝

As you describe it, it sounds like your getting a permission denied error trying to run /bin/sh; 正如您所描述的,这听起来像是您尝试运行/ bin / sh时遇到了权限被拒绝的错误; it seems more likely that you misread the error. 您似乎更可能误读了该错误。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM