I ran a small program that executes a given command using execvp (). It works fine when redirection is not used, but when I run the command, for example:
cat file1.txt > redirected.txt
cat displays the following error messages and failure:
cat: >: No such file or directory cat: redirected.txt: No such file or directory
I did a bit of work, and I'm starting to think that maybe execvp () cannot do the redirection because it does not start in the shell. Does this mean that I will have to manually select when the redirection happens and use pipes in my fork / exec code to get around this limitation? Is there a better way than using execvp ()?
Thanks!
source share