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.
6 comments:
What PHP version are you using? It works fine on my box.
php version 5.2.1
I'm using 5.2.4. I've used spaces in the exec family of calls, not had a problem so far. Of course, all on *nix systems (perhaps the behaviour is different on Windows).
Yeah, I guess this problem for windows only, anyway try this snippet to reproduce the bug
---
$host = escapeshellarg('localhost');
// $host = 'localhost';
$command = "\"c:\\Program Files\\PostgreSQL\\8.2\\bin\\psql.exe\" -h $host --version 2>&1";
// $command = "c:\\progra~1\\PostgreSQL\\8.2\\bin\\psql.exe\" -h $host --version 2>&1";
$handle = popen($command, 'r');
$read = fread($handle, 2096);
print_r($command);
print_r($read);
pclose($handle);
---
The problem happen when escape the argument using quote. The commented line is the working one. Tested on php version 5.2.5
Express Your Unique Fashion Statement w/ Our Talent Designer Clothing! Fahion & Well-Crafted Clothing Should Not Be Expensive w/ Our Top-Level Supply Chain! Styles: Sexy, Elegant, Casual, Basic, Cocktail, Formal.
Write your essay online. BuyEssayFriend creates discipline essays among them: research papers, personal and law essays, thesis, and academic writings.
Post a Comment