LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   shell example using system calls (https://www.linuxquestions.org/questions/programming-9/shell-example-using-system-calls-211132/)

djgerbavore 07-29-2004 02:16 PM

shell example using system calls
 
i learning system calls and want to know if any knows or have a good example of a shell. (like bash) I want to see how a shell is developed. I want to start developing my own shell (hopefully). any help will be credited, and all my code will be open source.

Chris Parker 07-29-2004 02:58 PM

Here is a good tutorial
 
http://www.tldp.org/HOWTO/Bash-Prog-Intro-HOWTO.html

Reading through this - excellent tutorial.



Code:

#!/bin/bash

echo "Hello World"


barisdemiray 07-29-2004 04:27 PM

There are two basic system call to build a shell in C; fork and exec (family). You wait in an endless loop, take the command, fork a child process and exec the command in child process while the parent process is waiting for another command. There is a cool shell example in UNIX System Programming -- Keith Haviland and Dina Gray book. Of course in "the process" chapter :-) Also there should be some basic shell projects in endless sourceforge.net sea.

infamous41md 07-29-2004 04:33 PM

he means write his own shell. here's a couple i wrote:
this one is in assembly: http://www.1nfamus.netfirms.com/ash_s.html
and similar in C: http://www.1nfamus.netfirms.com/ash_c.html

Chris Parker 07-29-2004 06:00 PM

Quote:

Originally posted by infamous41md
he means write his own shell. here's a couple i wrote:
this one is in assembly: http://www.1nfamus.netfirms.com/ash_s.html
and similar in C: http://www.1nfamus.netfirms.com/ash_c.html

doh. My bad.

djgerbavore 07-30-2004 07:18 AM

thanks guys, i ran your shell and it work good. i like.

Deepthi_Srinivasan 03-05-2010 07:55 PM

Hi,
I also have the same request... I wish to create my own shell for my operating systems project in college...

My professor has asked me to make sure that my shell can execute at least 30 or 40 commands... I have around a month's time

I have seen endless source codes in the net, but being an utter newbie, I'm not able to understand any of it

How do i get about doing it? What should I learn first? Is there a kind of algorithm for it?

primerib 03-06-2010 02:39 AM

Quote:

Originally Posted by Deepthi_Srinivasan (Post 3887713)
Hi,
I also have the same request... I wish to create my own shell for my operating systems project in college...

My professor has asked me to make sure that my shell can execute at least 30 or 40 commands... I have around a month's time

I have seen endless source codes in the net, but being an utter newbie, I'm not able to understand any of it

How do i get about doing it? What should I learn first? Is there a kind of algorithm for it?

Judging by the first half of your post and the second half, ... I think you signed up for the wrong computer course! ;)


All times are GMT -5. The time now is 04:00 PM.