![]() |
|
#1
|
|||
|
|||
Need help supporting linux pipes in a C shell programI'm new to C shell programming. I started off with the limited shell program listed. The program compiles and runs great, but does not support pipes ("|"), redirection of stdin, stdout and stderr just like Linux does.
Does anyone have any ideas on how this can be implemented in the C shell. The code was too long to paste here. I have attached a txt file myshell.txt. Also see link below: linuxgazette.net |
|||
|
#2
|
|||
|
|||
Re: Need help supporting linux pipes in a C shell programQuote:
Typical Linux distributions for PCs ship with the bash shell, and source is available for your reference. (I actually browsed it a long time ago, but didn't find it very illuminating. Maybe I just wasn't motivated enough. I mean, all those goto statements! My head hurts just thinking of it.) Various other "real world" shells make their source available for your reference. One such is tcsh. Here's a quote from a comment in sem.sh.c, one of the 54 C source files in the current tcsh package: " * sh.sem.c: I/O redirections and job forking. A touchy issue!" In other words, it's not just a matter of a "fixup" of the verrry rudimentary (toy) shell from your reference. Here's a reference for tcsh: http://www.kitebird.com/csh-tcsh-book/ You can get source from here:ftp://ftp.astron.com/pub/tcsh/ A package named "busybox" is used on many embedded Linux systems. It comes with a shell called "ash". Kind of a clone of a cut-down bash. (Has i/O redirection and many other features of bash, but not command history, for example.) I haven't actually looked at the source for ash, but I have been through other parts of busybox, and I found some of the code almost understandable. You should be able to find some references on the web (including the source). Regards, Dave |
|
#3
|
|||
|
|||
Re: Need help supporting linux pipes in a C shell programI never wrote anywhere in my post that Linux or any operating system is a shell. If this is what my post implies, my apologies. What I meant to say was that I wanted my shell program to support Linux commands, which in fact it does. The only thing I cannot do from the shell was the of use pipes ("|").
Thanks for the information in the links though. |
|
#4
|
|||
|
|||
Re: Need help supporting linux pipes in a C shell programQuote:
I'm sorry if I sounded snippy, but that's what I thought you said. ("the program does not support...like Linux does".) Linux is a kernel. It does not have commands. Of course, I knew what you meant, and everyone talks about "Linux command lines" and stuff like that. Sometimes I have a hard time expressing my passion for precision in narrative (as well as in programming) without sounding grouchy. Thank you for your indulgence. Regards, Dave |
|
#5
|
|||
|
|||
Re: Need help supporting linux pipes in a C shell programSo, what you are doing is running a C program out of a bash environment, right?
And is the problem with fork and execve? Have you searched this list on "fork" etc.? That turns up several threads which may be helpful. One in particular is: http://www.gidforums.com/t-3369.html?highlight=fork I think someone was doing linux pipes not too long ago... I'm not a forking professional, but played around a little and remember getting into pthreads which I thought worked nicely as well. Do you have man pages on your distro? It's all there... If you were to reduce your code to just what is necessary to illustrate your problem it would probably get more views and so a better response from the forum. Last edited by Howard_L : 28-Nov-2007 at 10:53.
|
Recent GIDBlog
Not selected for officer school by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Need help supporting linux pipes ("|") | student28 | Computer Software Forum - Linux | 0 | 27-Nov-2007 21:26 |
| Two-Tier data dissemination code installation problem | nidhibansal1984 | Computer Software Forum - Linux | 6 | 16-Sep-2007 10:13 |
| How to make Linux shell calls in a C++ program | salmaz8347 | C++ Forum | 3 | 14-Oct-2005 06:59 |
| [TUTORIAL] Calling an external program in C (Linux) | dsmith | C Programming Language | 4 | 22-Apr-2005 13:30 |
| Call a C program through Linux shell script | nuwandee | C Programming Language | 3 | 29-Mar-2004 21:54 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The