shell - PHP - Execute an external command, but by passing an array, one for programme name, then arg1, then arg2, etc -
I have a PHP script that needs to be executed on programs that will work on files containing empty space in names. To execute external commands, most PHP functions (like exec ()
) take 1 string argument to execute the command line. However, you have to do things like escapeshellarg ()
to secure your input.
Is there a way to execute an external command in PHP with an array instead of:
exec ("ls -l" .escapeshellarg ($ filename));
I can go to:
exec (array ("ls", "-l", $ filename));
This will mean that I'm not worried about avoiding the debate. I want to avoid using escapeshellarg ()
, because I'm using a bug in the version that removes non-ASCII characters.
This functionality is in Java
It seems that PHP's builtin functions Is not possible with.
Comments
Post a Comment