Path Environment Variable

Hi.....

I'm kind of new to c programming in Unix...need help here.

Supposed to write a source code to support Path environment variable for my programming assignment for Spring semester.
but i'm kind of stuck. Could anyone out there assist me?

prompt> /bin/ls
My program could output the above command.
But I just need to type the command below to get the same output as above.
prompt> ls
But how can i go about doing it?

Quite simple add the path of the command to environment variable PATH like this
PATH=$PATH:/path/of/command (e.g PATH=$PATH:/bin).
The PATH variable contains path for commands separated with colon like
/usr/bin:/usr/local/bin/:/bin
these paths are looked sequentially for command whenever u give a command on shell prompt and upon finding the first one it executes it.
Hope thats clear.

Hi

Thanks for the help..however, can you elaborate on it abit so that i could code in my source file?

how am i going to start coding? -felt lost-

Sorry Tancy for I couldn't get u in my first reply. Since u had put this in Shell Q & A I mistook it for a question on shell. Anyway I can still help u a bit.

As I told u earlier the path of the command is stored in environment variable PATH. Now u have got two options to choose from either let Unix do the searching for u or u do it urself. If u use execlp or execvp Unix will do it for u.
But if u have decided to do the hard work urself I'll suggest u visit this link Writing Your Own Shell LG #111 it shall clear all ur doubts.

Regards
Rakesh