简体   繁体   中英

popen: 'sh: permission denied"

I'm trying to use popen. When I execute some system command (eg let's say ls or whatever) all works fine. But when I'm trying to execute my executable:

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

I get an error: sh: permission denied.

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.

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

As you describe it, it sounds like your getting a permission denied error trying to run /bin/sh; it seems more likely that you misread the error.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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