I have been having issues getting execl to work.
pid_t pid = fork();
if(pid<0) {
perror("fork error\n");
} else if( pid== 0){
execl("/home/"user name"/opSys", "ps", ">>", "test.txt", (char*)NULL);
} else {
int returnStatus;
waitpid(pid, &returnStatus, 0);
}
I am attempting to get it to run the command and then output to my text file, however nothing happens. I have been googling and trying what i find, such as different exec's. I have tried execlp(), I have tried to just get it to use ps ant not put it into a file.
I do apologize if this has been answered, which I am sure it has, however I cant find a solution that is working for me. Thanks in advance.