Thread: Creating a Unix Shell in C

  1. #1
    Registered User
    Join Date
    Nov 2005

    Creating a Unix Shell in C

    I am trying to code, in C, a shell similar to that of Unix, with file execution functionality. I would like my shell to provide a command prompt to the user and if the input was an executable file name, then execute the file (like in any other OS). I know I have to use execv() and fork() as well as the process-id (pid) concept from the unistd.h library, but I am entirely confused on how to approach this problem. Any help is greatly appreciated.

    P.S> I just realized I should've posted this in the Linux/Unix forum. Apologies.
    Last edited by Opel_Corsa; 10-11-2006 at 09:55 PM.

  2. #2
    Registered User Jaqui's Avatar
    Join Date
    Feb 2005
    okay, like which shell in linux / unix / irix / *bsd?
    there are 10 that I know of, and each has it's own quirks and features.

    the original shell was sh
    the most commonly mentioned shell now is bash [ born again sh ]

    My usual reply to thequestion of coding a shell:

    why not get the sources for one of the available shells and use those as a reference?
    a shell is the system interface between the kernel and the user, every os has a shell that stands as a command interpreter between the user and the kernel.

    italicised to emphasize hints for thinking about the project goals
    Quote Originally Posted by Jeff Henager
    If the average user can put a CD in and boot the system and follow the prompts, he can install and use Linux. If he can't do that simple task, he doesn't need to be around technology.

  3. #3
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    The edge of the known universe
    IIRC, there are several attempts in this very forum, so why not study some of those.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Profiler Valgrind
    By afflictedd2 in forum C++ Programming
    Replies: 4
    Last Post: 07-18-2008, 09:38 AM
  2. Creating Shell based game..Few questions
    By Saintdog in forum Game Programming
    Replies: 1
    Last Post: 12-01-2004, 08:14 PM
  3. Running 'exec' twice in one UNIX shell script
    By Zughiaq in forum Tech Board
    Replies: 2
    Last Post: 05-03-2003, 12:04 AM
  4. unix shell
    By duffy in forum Tech Board
    Replies: 3
    Last Post: 10-16-2002, 03:11 AM
  5. Creating a Menu-Browser in Unix
    By Unregistered in forum C Programming
    Replies: 3
    Last Post: 04-07-2002, 09:56 AM