11 February 2008

php popen whitespace bug in windows

This popen path with whitespace bug, http://bugs.php.net/bug.php?id=40988&edit=1 make my day worse. Tired from long 9 hours journey from 'balik kampung', arrive at 3.30am and 8.30am go to office, huh. Then have to debug why the stupid php don't want execute the command.

I want use php to backup a postgis table. So

system('"C:\\Program Files\\PostgreSQL\\8.2\\bin\\pg_dump.exe" -t project_geom projectgis > '.$backup);


that, should straight forward, but the output is empty page. Then use popen to redirect the stdout and stderr, 2>&1 for debugging, I get this message

'C:\Program' is not recognized as an internal or external command, operable program or batch file.


Tried many technique to solve: escapeshellarg(), backslash to slash, all lowercase, etc, then afters spent hours debugging, it was the php problem, not my code. grrr.

BTW:
A 8.3 name (PROGRA~1) will still work on Windows, if it's not disabled
in the NTFS settings.
Post a Comment