Jump to content

Building a Shell in C finding help plz

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
7 replies to this topic

#1
lhy990084

lhy990084

    Newbie

  • Members
  • Pip
  • 2 posts
1.the command line interpreter checks whether the input command line matches a pre-defined lanaguage or not..If yes the os shell checks and invokes the programs specified in the input command line..else wait command line..
2.process creation..
Find the programs..with absolute path or relative path
3.i/o redirection
Rule [command name][arg]*<[filename]
4. detecing process termination and susupension.

5. signal handling.. such as Ctrl+Z and Ctrl+C

that are some problems..i cant solve it... finding help plz..>.< can some one gives me some hints..or some pseduo code...or lay out..i am stumming on it.now

#2
dargueta

dargueta

    Writes binary right handed and hex left handed

  • Moderators
  • 4,709 posts
This sounds a lot like homework. Try to come up with a plan, and at least show us that. Pseudocode isn't really that difficult to come up with. What OS are you compiling for?

#3
G_Morgan

G_Morgan

    Programming God

  • Members
  • PipPipPipPipPipPipPip
  • 537 posts

dargueta said:

This sounds a lot like homework. Try to come up with a plan, and at least show us that. Pseudocode isn't really that difficult to come up with. What OS are you compiling for?

Sounds like a Unix.

Best option is to look up the POSIX system calls.

#4
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
Another question is: what commands will you support? Will you be displaying error messages?

It looks like you haven't fully posted your instructions, either. For example, while this is a definition of a shell, it doesn't indicate whether you must create a shell, write a paper on those aspects of a shell, or something else.
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#5
lhy990084

lhy990084

    Newbie

  • Members
  • Pip
  • 2 posts
yes it is on UniX.. i dont how to write.. (when user typing some command which is correct or not..if correct the process creation.. it give some tips for me .. (use fork system call and exec system call..) but i have type many time..i cant do it..

#6
dargueta

dargueta

    Writes binary right handed and hex left handed

  • Moderators
  • 4,709 posts
So you don't know what commands you're going to support? Come up with a list of the ones you use most often, and support those. Pick maybe 10 at most to begin with.

#7
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
Basically: you have to
1) accept a string
2) be able to parse the string to determine what should be done
3) determine if any of the involved commands return an error (does not exist or fails on the input)

I would start with something simple, like supporting basic commands such as ls, mv, etc.
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#8
Aereshaa

Aereshaa

    Programming God

  • Members
  • PipPipPipPipPipPipPip
  • 790 posts
The way to actually do that is to fork(), and then in one process, execl() another program.