I am running this line in various server with various configuration:
<?php shell_exec("printf \"Hello World\" > result.txt");
In some servers the result.txt will have:
Hello World
But in others, I get:
"Hello World"
How can I prevent bash to add the double quote?
Just don't wrap it in quotes? Escape the space instead.
<?php shell_exec("printf Hello\ World > result.txt");
We can further simplify the command so that no quotes are needed:
<?php shell_exec("echo Hello World > result.txt");