LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   How to Write a Shell using C++ or C??? (https://www.linuxquestions.org/questions/programming-9/how-to-write-a-shell-using-c-or-c-547514/)

Non-Phixion 04-20-2007 01:16 AM

How to Write a Shell using C++ or C???
 
Can anyone help me out here????

I am trying to write a Shell using C++,
I wanna use the fork() and exec() functions in unix,
I wanna try come up with an output such as:

my shell $ <...type in commands...>

and the commands should basically execute as on a normal bash shell.

would be great if anyone can help me find any information which makes pipes and redirection clear if possible with source code.

Thanks...

wjevans_7d1@yahoo.co 04-20-2007 02:22 AM

For a thorough introduction to Unix programming, including pipes and I/O redirection, see:

Code:

http://www.faqs.org/docs/artu/
I suspect that Dr. Saffioti wants you to do your own work, but for all the source code you'll ever need on this subject:

Code:

http://www.gnu.org/software/bash/
Hope this helps.

Non-Phixion 04-20-2007 12:10 PM

Thanx...

I looked it up very helpful

haydari 04-20-2007 01:16 PM

I had an assignment last week about writing a basic shell terminal program which parses the command line, forks and passing the proper arguments with path to execv, letting execv handle the job.

If you are interested in something like this, you should do this using a main loop, getting the command line with readline, parsing it (I had a simple parse code, doesn't support complex commands), adjusting the input output redirection flags and pipe flags, then forking and calling execv.


All times are GMT -5. The time now is 10:59 AM.