954,500 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

I DON'T WANT TO USE ''exec Is" command

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

motswana
Newbie Poster
3 posts since Oct 2004
Reputation Points: 10
Solved Threads: 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?

alc6379
Cookie... That's it
Team Colleague
2,820 posts since Dec 2003
Reputation Points: 186
Solved Threads: 147
 

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

Narue
Bad Cop
Administrator
15,460 posts since Sep 2004
Reputation Points: 6,464
Solved Threads: 1,401
 
>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.

alc6379
Cookie... That's it
Team Colleague
2,820 posts since Dec 2003
Reputation Points: 186
Solved Threads: 147
 

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

Narue
Bad Cop
Administrator
15,460 posts since Sep 2004
Reputation Points: 6,464
Solved Threads: 1,401
 

sound like a hw assignment i had...

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

jaeSun
Light Poster
31 posts since Oct 2004
Reputation Points: 12
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You