Creating a Unix Shell in C

This is a discussion on Creating a Unix Shell in C within the Linux Programming forums, part of the Platform Specific Boards category; I am trying to code, in C, a shell similar to that of Unix, with file execution functionality. I would ...

  1. #1
    Registered User
    Join Date
    Nov 2005
    Location
    Canada
    Posts
    80

    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
    Posts
    416
    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 wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,659
    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.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

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, 07: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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21