Quote:
Originally Posted by
alister
A few items that stand out:
* execl will not do path lookup for "grep".
* read2 prototype doesn't agree with its definition
* fork returns pid_t which you are assigning to an int.
Either your friend mistook printf output for success or they had grep in the current working directory.
Regards,
Alister
I'm using ubuntu 11.04 and compiling with: "gcc filename.c -o filename" or "gcc -g filename.c -o filename " when I have to debug using GDB.
Alister, can you explain me what you meant by
* execl will not do path lookup for "grep".
* read2 prototype doesn't agree with its definition
?
When I use perror I get an error "No such file or directory".
I don't understand why because when I launch the terminal and use "ls" to list all the files, of course I see the file I'm calling the program with. However even if I change the file name for another one or either the file source I still get the same error.
grep works like that, right ? GREP -C PATTERN FILE
so my command line is execl("usr/bin/grep", "grep", "-c", stringa, file, NULL); its supposed to execute GREP -C STRING FILE
but I still get the error.
does anyone can explain me why I'm so blind that I can't see where the problem is ?