Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在尝试使用popen。当我执行一些系统命令(例如,让我们说 ls 或其他)时,一切正常。但是当我试图执行我的可执行文件时:
pipe = popen("./ <path>","r");
我收到一个错误:sh:权限被拒绝。
两个可执行文件(使用 popen 和我想从第一个启动的那个)都属于我的用户帐户并具有“x”权限。
我会仔细检查该错误消息,因为它应该说明权限被拒绝也涉及什么。即如果路径为空,并且您刚刚通过了./,或者像您的示例中那样有一个额外的空间,您应该看到
sh: ./: 权限被拒绝
正如您所描述的,听起来您在尝试运行 /bin/sh; 时遇到权限被拒绝错误;您似乎更有可能误读了该错误。