PLEASE HELP ME, I WANT TO WRITE A C PROGRAM TO EMULATE THE
Is -L -A -F UNIX COMMAND THAT WILL DISPLAY ALL FILES IN THE CURRENT DIRECTORY INCLUDING INVISIBLE FILES, THEIR ACCESS PRIVILEGES, AS WELL AS IDENTIFYING WHICH ARE FILES AND WHICH ARE SUB-DIRECTORIES. but i dont want to use exec ls command

here is the program using execl

main()
{ printf(``Files in Directory are:n'');
execl(`/bin/ls'',``ls'', ``-l'',0);
}

Edited 3 Years Ago by happygeek: fixed formatting

Why not just take the source code for the Linux ls command, and hack it to your liking, so that it automatically includes those options? Then, you could compile it, rename it, and use it as you wish.

I haven't looked at the source, but I imagine each of those options is a function, and you could just have it call those functions in addition to its default behaviour. Why reinvent the wheel?

>but i dont want to use exec ls command
Why not? It does the job and is much easier to get right than the equivalent code using opendir, readdir, closedir, and stat.

>but i dont want to use exec ls command
Why not? It does the job and is much easier to get right than the equivalent code using opendir, readdir, closedir, and stat.

Maybe it's an exercise in using those functions? Just a guess here.

>Maybe it's an exercise in using those functions?
Homework, possibly. Though I doubt it's a specific exercise otherwise the OP would have a good idea of what to search for and the question would not have been nearly as vague.

sound like a hw assignment i had...

we had to program a "shell" to take in certain commands and display it to the screen ...

This article has been dead for over six months. Start a new discussion instead.