I want to run something like
cat file.tar | base64 | myprogram -c "| base64 -d | tar -zvt "
I use execlp
to run the process.
When i try to run something like cat
it works, but if i try to run base64 -d | tar -zvt
it doesn't work.
I looked at the bash commands and I found out that I can run bash and tell him to run other programs. So it's something like:
execlp ("bash", "-c", "base64 -d | tar -zvt", NULL);
If I run it on the terminal, it works well, but using the execlp
it dont work.
If I use execlp("cat", "cat", NULL)
it works.
Someone knows how to use the -c
param on execlp to execute multiple "programs"?
I cant use system because i use pipe and fork.
Now i noticed, if i try to use execlp("bash", "bash", "-c", "base64", NULL)... nothing happens. If i use execlp("cat", NULL) it's ok.. I'm writing to the stdin... i don't know if its the problem with the bash -c base64.. because if i run on the terminal echo "asd" | bash -c "cat" it goes well