does execlp need a path?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
if(pid==0){

                execlp(cmd.c_str(), (char*)cmd.c_str(),0);//I entered just ls and it lists the files
                _exit(EXIT_SUCCESS);

                }



            //wait for child
            else{
                int status;
                waitpid(pid, &status, 0);


                }


how come manual says it needs a path then?
Last edited on
$ echo $PATH
If the [first] argument contains a slash character, it is used as the pathname for this file. Otherwise, the path prefix for this file is obtained by a search of the directories passed in the PATH environment variable
thanks..didnt know that
That's from the documentation for the function, in the very first hit that Google gives you when you search for the function name.

You need to make a little more effort to read the documentation that's easily available. Asking people here to copy and paste information that you're too lazy to find, is, frankly, an abuse of this forum and of the people who give up their time to help others.
well, may be in your place you get hits but in my place I do not get such hits, a lot of efforts have been wasted on this from my part...
@MikeyBoy
Let's not abuse the young padawans for their failure to be as awesome as we are. Learning to google stuff properly (and especially to read *nix documentation!) is an acquired skill. The forum exists for all questions -- even dumb ones.

Hope you feel better.
Topic archived. No new replies allowed.