Close stdin and stdout to use redirection with a unix shell
Posted on 2005-04-29
I am creating my own shell to work as a unix shell (bash or other). I have gotten it to work with things like ls and pwd using execvp(), but I also want to be able to handle redirection like ls > out.txt. I think that I have to first close stdout and open out.txt before i call fork, but using this code:
if (!strcmp(command[i], ">"))
I get error: STDOUT' undeclared (first use in this function).
I also tried stdout, but got the same error. Am I missing a header?
Hope someone can help me