I've found a problem with exec, passthru, shell_exec & system.
I'm trying to run the following
exec("sort -r -n -k2,2 r1.txt > r2.txt")
with r1.txt being a numeric file. The file looks like this:
237 291 845 152 585 3
193 810 173 484 151 3
366 491 910 265 893 3
220 631 571 332 104 3
502 567 854 40 108 3
639 13 720 101 482 3
254 676 896 759 720 3
907 928 377 899 778 3
324 194 995 161 708 3
501 936 716 105 209 3
(The file is actually 1500 lines long, but this gives you an idea.
It's tab delimited, and the numbers are random: I created the file
using awk to test this).
Here's the problem:
If I run it with exec, passthru, shell_exec or system, THE FILE GETS
TRUNCATED. Instead of 1500 lines, I get 1338. But if I run the SAME
COMMAND in the shell (manually), THE SORT WORKS OK!
I run this in other files and the result is the same: the file gets
truncated. Also, I checked for special characters, but there are none:
the file contains just regular numbers and tabs. The problem seems to
be PHP since when I run the command manually I get correct results...
Any ideas?
Thanks.
I'm trying to run the following
exec("sort -r -n -k2,2 r1.txt > r2.txt")
with r1.txt being a numeric file. The file looks like this:
237 291 845 152 585 3
193 810 173 484 151 3
366 491 910 265 893 3
220 631 571 332 104 3
502 567 854 40 108 3
639 13 720 101 482 3
254 676 896 759 720 3
907 928 377 899 778 3
324 194 995 161 708 3
501 936 716 105 209 3
(The file is actually 1500 lines long, but this gives you an idea.
It's tab delimited, and the numbers are random: I created the file
using awk to test this).
Here's the problem:
If I run it with exec, passthru, shell_exec or system, THE FILE GETS
TRUNCATED. Instead of 1500 lines, I get 1338. But if I run the SAME
COMMAND in the shell (manually), THE SORT WORKS OK!
I run this in other files and the result is the same: the file gets
truncated. Also, I checked for special characters, but there are none:
the file contains just regular numbers and tabs. The problem seems to
be PHP since when I run the command manually I get correct results...
Any ideas?
Thanks.
Comment