0

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 by happygeek: fixed formatting

4
Contributors
5
Replies
6
Views
12 Years
Discussion Span
Last Post by jaeSun
0

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?

0

>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.

0

>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.

0

>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.

0

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 topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.