Hey guys,
So im working on this project which is create a shell in C using fork() and execve() commands in POSIX.
The main things is a read_command() functions and a main which just has a while loop with fork and execve with an if statement that takes out the waitpid() command if the user types <command> & which means they want to run it in the background.
Now what i am trying to do is make it so instead of having to type a command such as /bin/ls or /usr/bin/xeyes to be able to jsut type "ls" or "xeyes" and so on. Is there anyways that i can get the system environment paths?
or can someone gimme a hint as to how to go about this problem?
Note: i am not asking for you to do it nor am i asking for u to give me the code
nnobakht
0
Light Poster
Recommended Answers
Jump to PostThe 'exec' calls with a 'p' in the name perform the job of searching the PATH.
Jump to PostYou mean like
char *p = getenv("PATH");Then you parse that string, looking for directories, then testing each in turn?
All 5 Replies
Salem
5,138
Posting Sage
nnobakht
0
Light Poster
Salem
5,138
Posting Sage
nnobakht
0
Light Poster
Salem
5,138
Posting Sage
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.