GIDForums  

Go Back   GIDForums > Computer Programming Forums > C Programming Language
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 25-Sep-2009, 02:44
noname007 noname007 is offline
New Member
 
Join Date: Sep 2009
Posts: 2
noname007 is on a distinguished road

Unix Shell in C


Hi,
I am new to programming in C. I have to create a unix shell that can implement 1. basic commands such as ls, pwd, mkdir etc
2. can implement redirection
3. pipelining

Any help on where to start from or source codes will be appreciated
Thank You
  #2  
Old 25-Sep-2009, 05:01
L7Sqr L7Sqr is offline
Member
 
Join Date: Jul 2005
Location: constant limbo
Posts: 234
L7Sqr is a jewel in the roughL7Sqr is a jewel in the rough

Re: Unix Shell in C


You can look at bash source code, although being that you are a novice this may be hard to swallow.
There is little out there in terms of building your own shell (at least that I have seen) as it is a non-trivial process.
How long do you have and what is your background?
__________________
My personal site: Utilities for text processing, debugging, testing and plotting
  #3  
Old 25-Sep-2009, 07:29
Mexican Bob's Avatar
Mexican Bob Mexican Bob is offline
Member
 
Join Date: Mar 2008
Location: Chicxulub, Yucatán
Posts: 226
Mexican Bob is a jewel in the roughMexican Bob is a jewel in the roughMexican Bob is a jewel in the rough

Re: Unix Shell in C


Quote:
Originally Posted by noname007
Hi,
I am new to programming in C. I have to create a unix shell that can implement 1. basic commands such as ls, pwd, mkdir etc
2. can implement redirection
3. pipelining

Any help on where to start from or source codes will be appreciated
Thank You

Maybe start with "ash" from the Busybox project?


MxB
  #4  
Old 25-Sep-2009, 12:37
noname007 noname007 is offline
New Member
 
Join Date: Sep 2009
Posts: 2
noname007 is on a distinguished road

Re: Unix Shell in C


hey guys,
Thanks for the quick reply. I am familiar with a bit of UNIX but not at all with C or any other programming languages. I know the basic commands in UNIX. I did go through some source codes but they all went over my head. I checked some tutorials of C but still i could not get anything when i went through the source codes. This thing is killing me
  #5  
Old 25-Sep-2009, 14:03
L7Sqr L7Sqr is offline
Member
 
Join Date: Jul 2005
Location: constant limbo
Posts: 234
L7Sqr is a jewel in the roughL7Sqr is a jewel in the rough

Re: Unix Shell in C


Dont get discouraged; persistence pays off.
Start small by writing the main execution loop. Thats basically all a shell does is process input in a loop and hand functionality off to the proper executables. Scripting is a bit more involved, but lets leave that for now.
The main loop should look something like:
Code:
print prompt while user_hasnt_quit accept the next line of input print the previous line of input print prompt loop
This is not C code, but can easily be converted. Get that working and you can start to move to parsing the input you got.
__________________
My personal site: Utilities for text processing, debugging, testing and plotting
 
 

Recent GIDBlogOnce again, no time for hobbies by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Make a Unix shell in C james_carter C Programming Language 4 25-Feb-2009 13:56
Probing for TCP connections kterry C Programming Language 3 14-Feb-2008 12:32
get the local host ip in unix os kmathanbe C++ Forum 2 02-Jan-2007 22:46
C++ on Unix.. aleppos C++ Forum 18 05-Jun-2005 23:11
Call a C program through Linux shell script nuwandee C Programming Language 3 29-Mar-2004 22:54

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 02:44.


vBulletin, Copyright © 2000 - 2009, Jelsoft Enterprises Ltd.