Здравствуйте. Помогите пожалуйста найти ошибку в коде
| Код | #include <fcntl.h> #include <string.h> #include <stdlib.h> #include <errno.h> #include <stdio.h> #include <netinet/in.h> #include <resolv.h> #include <sys/socket.h> #include <arpa/inet.h> #include <unistd.h> #include <sys/types.h> #include <sys/wait.h> /* * */ int main (int argv, char** argc) { int pfildes[2]; pid_t pid; if (pipe(pfildes) == -1) {perror("error creating pipe"); exit(1);} if ((pid = fork()) == -1) {perror("error creating child process"); exit(1);} else if (pid == 0) { /* child: */ close(pfildes[0]); /* close read end of pipe */ dup2(pfildes[1], 1); /* make 1 same as write-to end of pipe */ close(pfildes[1]); /* close excess fildes */ execlp("ls", "-1", NULL); perror("error executing child process"); /* still around? exec failed */ _exit(1); /* no flush */ } else { /* parent: */ int status; waitpid(pid, &status, 0); if (WIFEXITED(status)) { printf("[ls] executed ok"); } else { perror("error executing child process"); } close(pfildes[1]); /* close write end of pipe */ dup2(pfildes[0],0); /* make 0 same as read-from end of pipe */ close(pfildes[0]); /* close excess fildes */ execlp("cut", "-c", "44-56", NULL); perror("error executing child process"); /* still around? exec failed */ exit(1); }
}
|
Хочу запустить этим кодом вот такую сложную команду
| Цитата | ls -l | cut -c 44-56
|
пробую запустить, но получаю
| Цитата | -c: you must specify a list of bytes, characters, or fields Try `-c --help' for more information.
|
|