I am writing a mini shell, but I am having trouble with input/ output redirection when it comes to reading the input from one file, execute a command on that input and then redirect the output to another file.
An example would be:
tac <myInput >myOutput
I was able to write the code if there was either one of the two (input or output), but I'm having trouble with the code for using both of them at the same time.
I tried creating a pipe but I was unsuccessful.
This is what I did (the program is pretty big so I will just show the pipe part)
sd1 = open(files,O_WRONLY|O_CREAT|O_TRUNC,S_IRWXU);
sd2 = open(files,O_RDONLY,S_IRUSR|S_IWUSR);
execvp(comm,comm); // this is the command line within my shell
else if (fork()>0)
Any help would be appreciated.