|
Home > Archive > Unix Programming > August 2006 > Writing a shell program
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Writing a shell program
|
|
| souissipro 2006-08-26, 7:45 am |
| Dear ALL,
I'm C and shell beginner and I should write a sheel that does the
following:
- reads an input line from standard input, parses the line into
commands and arguments, calls the command with the arguments and waits
for it to terminate.
- includes i/o redirection, environment variables, parameter and
command substitution, command line editing and filter management.
I would greatly appreciate if anybody could provide me with a shell
that has the functionalities mentionned above and that I can start with
my learning?
Thank you very much for your help,
Beginner
| |
| Barry Margolin 2006-08-26, 1:24 pm |
| In article <1156594812.061843.83190@m79g2000cwm.googlegroups.com>,
"souissipro" <souissipro@yahoo.fr> wrote:
> Dear ALL,
>
> I'm C and shell beginner and I should write a sheel that does the
> following:
> - reads an input line from standard input, parses the line into
> commands and arguments, calls the command with the arguments and waits
> for it to terminate.
> - includes i/o redirection, environment variables, parameter and
> command substitution, command line editing and filter management.
That's a pretty complex task for a beginner. I think you should start
with some simpler projects, and work your way up to this.
--
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
*** PLEASE don't copy me on replies, I'll read them in the group ***
| |
|
| On 26 Aug 2006 05:20:12 -0700
"souissipro" <souissipro@yahoo.fr> wrote:
> I'm C and shell beginner and I should write a sheel that does the
> following:
> - reads an input line from standard input, parses the line into
> commands and arguments, calls the command with the arguments and
> waits for it to terminate.
> - includes i/o redirection, environment variables, parameter and
> command substitution, command line editing and filter management.
>
> I would greatly appreciate if anybody could provide me with a shell
> that has the functionalities mentionned above and that I can start
> with my learning?
>
> Thank you very much for your help,
Hum, nice task, how long do you have to do it?
To begin with you are going to know how to do string handling functions
to separate various parts of the command, broken with & ; | > and <.
Once you have the various parts you then have to look at whats the
execution and whats the parameters.
Once you have figured out the above you then have to know what to
execute, this is done with the fork, exec and pipe syscalls.
I recommend you prototype this first in something like PERL or python,
writing 100 lines of c can take a while, so while you're experimenting
you should use a simple language that gets you what you need prior to
putting in all the time with C.
--
Regards, Ed :: http://s5h.net/u?l
just another linux hacker
Contrary to what meteorologists say, wind is only the effect of Chuck
Norris' breathing patterns.
| |
| bwaichu@yahoo.com 2006-08-27, 7:25 pm |
|
souissipro wrote:
> Dear ALL,
>
> I would greatly appreciate if anybody could provide me with a shell
> that has the functionalities mentionned above and that I can start with
> my learning?
>
This is the underlying topic of the book "Advanced Unix Programming
2nd Ed" by Marc Rochkind. Each chapter slowly builds you towards
writing a working shell. There is a lot involved.
Your other option is to read source code from one of the many shells.
But, I think, the book approach is less painful.
| |
|
| On 27 Aug 2006 15:42:08 -0700
"bwaichu@yahoo.com" <bwaichu@yahoo.com> wrote:
> This is the underlying topic of the book "Advanced Unix Programming
> 2nd Ed" by Marc Rochkind. Each chapter slowly builds you towards
> writing a working shell. There is a lot involved.
>
> Your other option is to read source code from one of the many shells.
> But, I think, the book approach is less painful.
The book is not just about writing a working shell, it covers so much
more. Personally I've read this cover to cover and gone back to it many
times.
Although, I didn't think the networking section was that great, it could
have used a bit more content about TCP/IP. For TCP/IP I recommend the
Beej's guide to TCP Programming. Many sources on google for that.
--
Regards, Ed :: http://www.gnunix.net
proud Python person
When Mr. T gets hot or nervous, he starts sweating bullets. 50-cal.
hollow-point bullets.
| |
| jmcgill 2006-08-28, 1:42 pm |
| ed wrote:
> Although, I didn't think the networking section was that great, it could
> have used a bit more content about TCP/IP. For TCP/IP I recommend the
> Beej's guide to TCP Programming. Many sources on google for that.
Don't neglect the immortal works of the late W. Richard Stevens.
| |
|
| On Mon, 28 Aug 2006 11:23:53 -0700
jmcgill <jmcgill@email.arizona.edu> wrote:
>
> Don't neglect the immortal works of the late W. Richard Stevens.
Oh! I was unaware that WRS had passed on. I wonder who gets the funds
from his book sales now, does it all go to the publisher or does one of
his close family get the profits?
--
Regards, Ed :: http://www.openbsdhacker.com
proud bash person
Vin Diesel's native tongue is L337.
| |
| jmcgill 2006-08-28, 7:32 pm |
| ed wrote:
>
> Oh! I was unaware that WRS had passed on. I wonder who gets the funds
> from his book sales now, does it all go to the publisher or does one of
> his close family get the profits?
He was survived by a wife and several children. He was a smart guy.
Addison-Wesley is a reasonable publisher. I know that his estate made a
substantial gift to a particular Episcopal church here in Tucson, and
also to the local chapter of Habitat for Humanity. But as to who gets
royalties now for the book sales, I don't even know if that information
is public. No reason to believe there's any shenanigans.
|
|
|
|
|