Hi, I have a very small program where I call execlp() to execute sort.
Everything works fine. But sort has a -T option which can be used to specify a temporary directory. Now when I use -T with execlp() it does not work.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <fcntl.h>
#include <errno.h>
int main(int argc, char *argv[])
{
int ret;
ret = execlp("sort","sort","hugefile.txt","-T /u/mmr/somedir",NULL);
if (ret == -1) {
fprintf(stderr, "Could not sort file (%s)", strerror(errno));
exit(1);
}
return(1);
}
sort when called using execlp() is unable to find the specified directory "somedir"
This is the error that I get.
However when I run the same command from the shell. Things work fine:
does anybody have a clue on what might be going on? any input will be appreciated!