LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 09-19-2011, 04:52 AM   #1
shlinux123
LQ Newbie
 
Registered: Sep 2011
Posts: 2

Rep: Reputation: Disabled
Creating a simple program to list directory in C under linux


Hi experts!
I am in quick need of your expertise.
I have been trying for the past few days to do the following under linux but am failing consistently.

I have a task to create a simple program in C which starts and prompts in the format of user@host: work_dir $
I need it to list the current directory when I input the command "ls"
I need it to close when I press quit.
Can someone please guide me in the right direction.

Unfortunately I do not have much history of using linux apart from using it for my HTPC and for my SIP server.

Any help will be greatly appreciated,
Thanks,
shlinux123

Last edited by shlinux123; 09-19-2011 at 05:03 AM.
 
Old 09-19-2011, 06:46 AM   #2
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443
Blog Entries: 3

Rep: Reputation: 720Reputation: 720Reputation: 720Reputation: 720Reputation: 720Reputation: 720Reputation: 720
Quote:
Originally Posted by shlinux123 View Post
I need it to list the current directory when I input the command "ls"
You want to replace the "ls" command?

Quote:
Originally Posted by shlinux123 View Post
I need it to close when I press quit.
Is it supposed to be a GUI application?
 
Old 09-19-2011, 01:25 PM   #3
shlinux123
LQ Newbie
 
Registered: Sep 2011
Posts: 2

Original Poster
Rep: Reputation: Disabled
Thanks for the reply MTK358, I appreciate it.

Quote:
Originally Posted by MTK358 View Post
You want to replace the "ls" command?
I want the normal function of ls, to list the contents of a directory

Quote:
Is it supposed to be a GUI application?
No, It should be a command line interface, a close button or similar would be perfectly fine.(like in the top right corner of the window)

Basically I need the normal shell prompt, but with only the functionality of having the "ls" command.
I know you can normally change the prompt of BASH with -

Quote:
export PS1='\u@\H: \W $'
I want the same type of prompt.
Hope I'm making myself clear.
Thanks,
shlinux123

Last edited by shlinux123; 09-19-2011 at 01:26 PM.
 
Old 09-19-2011, 01:47 PM   #4
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443
Blog Entries: 3

Rep: Reputation: 720Reputation: 720Reputation: 720Reputation: 720Reputation: 720Reputation: 720Reputation: 720
I think you're extremely confused about the function of the shell, terminal, and commands.

The terminal is a program that displays text printed by a program.

The shell is a program that interactively lets you launch other programs (and sometimes offers some programming capability).

Commands are just independent programs.

None of the above three are integrated with or depend on any of the other two.
 
1 members found this post helpful.
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Error in Creating rpm package for a simple "Hello World" Program jayasekar Linux - Software 2 12-01-2009 09:26 AM
Creating a simple mail read only program ml41782 Linux - Newbie 8 07-18-2009 06:25 PM
simple list and driver program TurtleFace Programming 5 10-24-2006 01:40 PM
need simple program to manage a mailing list linuxlimbo Linux - Software 0 12-21-2004 06:30 AM


All times are GMT -5. The time now is 10:42 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration