calling awk from php not working

I want to run awk from php to do some text processing. I am giving an extremely simple example below:

onecol.awk file
-------------------

{
print "Hello!";
}

f1.txt
---------
aaa
ccc
eee

f2.txt
---------

ddd
eee
fff

----------

index.php
---

<?php
$command1 ="awk -f onecol.awk f1.txt > outsingle.txt";
exec($command1);

$command2 ="join <(awk -f onecol.awk f1.txt) <(awk -f onecol.awk f2.txt) > outdouble.txt";
exec($command2);
?>

In this php, first exec command works while the second one does not work. Why is it so?
There should not be any permission problem as the first exec command is creating the outsingle.txt file.

Both the commands work perfectly on console.

Thanks

exec replaces your program. Once you've done exec, your program no longer exists!

Try system().

I tried system() command also but not working .

In what way is system() not working?

---------- Post updated at 12:10 PM ---------- Previous update was at 12:04 PM ----------

You can't redirect two files into one program. Why not feed both files into one awk?

awk -f whatever file1 file2 > outdouble

I have variable number of files and I want to perform aggregate on each file and then combine. The related thread by me is on the following address.

That is why I wrote a code that create awk command for n number of files.

But I am stuck at this point as awk is not being executed when called from php.
Thanks

$command1 ="awk -f onecol.awk f1.txt > outsingle.txt";

I don't know if it is good form, but I do this

$command1 = `awk -f onecol.awk f1.txt`;

Then $command1 contains the output.

Thanks for reply.

I wrote a php code that creates the following command:

join -t$'\t' -a1 -a2 -e- -j1 -o0,1.2,2.2 <(awk -f agg.awk fff1.txt) <(awk -f agg.awk fff2.txt) |
join -t$'\t' -a1 -a2 -e- -j1 -o0,1.2,1.3,2.2 - <(awk -f agg.awk fff3.txt) |
join -t$'\t' -a1 -a2 -e- -j1 -o0,1.2,1.3,1.4,2.2 - <(awk -f agg.awk fff4.txt) |
join -t$'\t' -a1 -a2 -e- -j1 -o0,1.2,1.3,1.4,1.5,2.2 - <(awk -f agg.awk fff4.txt) |
join -t$'\t' -a1 -a2 -e- -j1 -o0,1.2,1.3,1.4,1.5,1.6,2.2 - <(awk -f agg.awk fff6.txt) > tmp.txt

My only concern now is why it does not work if I call from php.

My php file is:

<?php
$command ="awk -f onecol.awk f1.txt > outfirst.txt";
system($command);

$command ="join -t$'\\t' -a1 -a2 -e- -j1 -o0,1.2,2.2 <(awk -f agg.awk fff1.txt)     <(awk -f agg.awk fff2.txt)  >  outsecond.txt ";
system($command);
?>

Thanks