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);
}

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

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.