Reputation: 6335
I have this command:
exec(sprintf('%s %s dump_data output', escapeshellarg($apps . 'pdftk' . DIRECTORY_SEPARATOR . 'pdftk.exe'), escapeshellarg(self::winEscapeShellArgFix($file, array()))), $output);
the result of sprintf is this:
"\\127.0.0.1\binary\win32\pdftk\pdftk.exe" "//127.0.0.1/uploads\1-16knje01g1drjagii61j3515a94.pdf" dump_data output
running this command from exec will give no result, but if I run it from windows cmd it will work correctly. After I trying millions of commands I understand that the problem is that php is using as escape backslash the backslashes inside the sprintf output:
**\\**127......
Any one knows why this happens? I have all magic OFF.
EDIT: if i will execute:
exec("\\127.0.0.1\binary\win32\pdftk\pdftk.exe //127.0.0.1/uploads\1-16knje01g1drjagii61j3515a94.pdf dump_data output",$outarr);
or
exec('\\127.0.0.1\binary\win32\pdftk\pdftk.exe //127.0.0.1/uploads\1-16knje01g1drjagii61j3515a94.pdf dump_data output',$outarr);
it will not work
EDIT2: I debug and it is not an escaping problem the command actually is good, IT seems to be a exec problem, that is not returning the output. it works in a iis web server but doesnt work in another iis webserver.
Upvotes: 2
Views: 2247
Reputation: 1141
albanx, it's not sprintf
doing it to you, its the escapeshellarg
which is adding the backslashes.
http://php.net/manual/en/function.escapeshellarg.php
Upvotes: 2