LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 07-29-2004, 02:16 PM   #1
djgerbavore
Member
 
Registered: Jun 2004
Location: PA
Distribution: Fedora (latest git kernel)
Posts: 458

Rep: Reputation: 30
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.
 
Old 07-29-2004, 02:58 PM   #2
Chris Parker
LQ Newbie
 
Registered: Jul 2004
Location: Houston, Texas
Distribution: Debian, Gentoo, Redhat
Posts: 17

Rep: Reputation: 0
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"
 
Old 07-29-2004, 04:27 PM   #3
barisdemiray
Member
 
Registered: Sep 2003
Location: Ankara/Turkey
Distribution: Slackware
Posts: 155

Rep: Reputation: 30
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.
 
Old 07-29-2004, 04:33 PM   #4
infamous41md
Member
 
Registered: Mar 2003
Posts: 804

Rep: Reputation: 30
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
 
Old 07-29-2004, 06:00 PM   #5
Chris Parker
LQ Newbie
 
Registered: Jul 2004
Location: Houston, Texas
Distribution: Debian, Gentoo, Redhat
Posts: 17

Rep: Reputation: 0
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.
 
Old 07-30-2004, 07:18 AM   #6
djgerbavore
Member
 
Registered: Jun 2004
Location: PA
Distribution: Fedora (latest git kernel)
Posts: 458

Original Poster
Rep: Reputation: 30
thanks guys, i ran your shell and it work good. i like.
 
Old 03-05-2010, 07:55 PM   #7
Deepthi_Srinivasan
LQ Newbie
 
Registered: Mar 2010
Posts: 1

Rep: Reputation: 0
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?
 
Old 03-06-2010, 02:39 AM   #8
primerib
Member
 
Registered: Mar 2010
Posts: 48

Rep: Reputation: 20
Quote:
Originally Posted by Deepthi_Srinivasan View Post
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!
 
  


Reply



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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
'sh' shell - Actually calls legacy Bourne shell, or uses system default? Dtsazza Linux - Software 1 10-28-2005 09:20 AM
New to C++. I need to learn system calls matazar42 Programming 7 05-01-2005 09:34 PM
Some system calls Spooky Programming 1 11-24-2004 10:17 AM
over riding system calls djgerbavore Programming 11 08-20-2004 12:03 AM
How to Write Own Shell in Unix using System Calls? indian Programming 2 08-05-2004 04:06 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:35 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration