#include #include #include extern char **environ; // simple example of redirecting stdout int main(void) { int fd = open("file.txt", O_RDONLY); if (fd < 0) { perror(""); return 1; } if (dup2(fd, 0) < 0){ perror(""); return 1; } // we won't use this. // we will read from the file.txt via fd from now on close(fd); char *tr_argv[] = {"/usr/bin/tr","a-z", "A-Z",NULL}; execve("/usr/bin/tr", tr_argv, environ); perror(""); return 0; }