Results 1 to 2 of 2
im writing a small shell in c that implments some basic shell functions. I need to be able to redirct output
ex. ls -al > output.dat
i was thinking i ...
- 03-13-2010 #1Just Joined!
- Join Date
- Mar 2010
- Posts
- 1
implement a shell in c
im writing a small shell in c that implments some basic shell functions. I need to be able to redirct output
ex. ls -al > output.dat
i was thinking i need to use the exec() function, which I have working where there is no redirection, but how do I get it to output that data to the new file
do i need to fork a new process to do this, and do I need to create the file first, or does the exec() function do that
little confused, and pointers would be great
- 03-14-2010 #2
This sounds a lot like a homework question, so I'm going to close this thread. Homework questions are not allowed on this forum.
I will, however, give you two pointers:
1) Go ahead and read this article for an overview of forking and execing:
Fork, Exec and Process control
2) Read these:
Standard streams - Wikipedia, the free encyclopedia
http://en.wikipedia.org/wiki/Redirection_(computing)
I/O redirection is set up by setting up the stdin, stdout, and stderr of a process before it is exec()'d (exec preserves stdin, stdout, and stderr). Hopefully this will point you in the correct direction.DISTRO=Arch
Registered Linux User #388732


