I want to implement a function for MapReduce framework so my task is to create a mapper that concatenate text files.
Here is my bash script;
for i in text1.txt text2.txt text3.txt
do
cat $i | ./myfunction
done
And myfunction() will read the input files , line by line and the variable will be read with function getenv(). I tried with fopen(argv[1],"r") it gives me Segmentation fault and with popen() I get permission denied.
My code in C++:
char *myenv;
myenv = getenv("PWD");
FILE *fileIN = popen(myenv , "r");
I don't know what exactly cat $i | ./myfunction does.Does it read "i" like an argument ? if yes, I get fileIN == NULL when I use fopen.