How it's possible that shell_exec give a different results than when the command is manually triggered? I'm executing
shell_exec('/usr/bin/wc --words ' . $filepath).
My PHP is 7.4.3 ,
I have also tried wc -w.
It gives a different output when is triggered manually from shell.
I have tested it with webmaster user from shell and its running under webmaster user on web.
I have tested this with running whoami. It just doesn't make any sense. It doesn't give any errors or anything, it just gives different outputs.
When I run it with webmaster from shell it gives a regular ouput, eq. exact number of words.
Anyone have any idea where to look since I have already tried users and permissions?
md5suminstead of/usr/bin/wc --words, does it show a different checksum?shell_execand which do you see in a shell for the same command withLC_ALL=Cin front?locale, which will show some variables. Copy the value forLC_CTYPEand put it in front of your command, for exampleLC_CTYPE="en_US.UTF-8" /usr/bin/wc --words arabian.txt. This should make the number match up with the correct one. Different languages and encodings have a different idea of what constitutes a word