jody
2013-01-06 13:50:50 UTC
Hi
I have a problem when creating a db dump from a php script in a html page.
This used to work in previous PostgreSQL versions, but now (v, 9.1.5)
it fails, and i have no idea why.
It is not a matter of write-access, since the directory has mode 777,
and in the same php-file i successfully create a file there.
Here's a minimal version which shows the behavior:
<html>
<head></head>
<body>
<?php
putenv('PG_USER=magnus');
putenv('PG_PASSWORD=mypass');
putenv('PG_DB=magnus2');
putenv('PG_HOST=localhost');
putenv('PGPASSFILE=/home/jody/.pgpass');
$sPath="/home/jody/progs/magnus2/dumps/dumpidump.sql";
$sDBName="magnus2";
$sQuery1="/usr/bin/pg_dump -w -U magnus -c -f $sPath $sDBName";
exec($sQuery1, $output, $iRet);
print("Q:" . $sQuery1 . "<br/>");
print("ret:" . $iRet . "<br/>");
foreach($output as $ss) {
print("out:" . $ss . "<br/>");
}
print("<hr/>\n");
$sQuery2="echo gnagna > " . $sPath . ".test";
exec($sQuery2, $output, $iRet);
print("Q:" . $sQuery2 . "<br/>");
print("ret:" . $iRet . "<br/>");
foreach($output as $ss) {
print("out:" . $ss . "<br/>");
}
?>
The call to pg_dump fails with a return code of 1, and $output is empty.
The second call succeeds with return code 0, and a file is indeed written.
When i replace $sQuery1 by "/usr/bin/pg_dump --version" the cal
succeeds with return code 0,
and $output contains the string "pg_dump (PostgreSQL) 9.1.5"
When i copy-paste the command contained in $sQuery to the command line,
it succeeds.
In my home directory /home/jody i have .pgpass file, with the correct
username and password.
Is there a way to specify a password on the command line?
Can somebody give me a hint how i can get this to work?
Thank You
Jody
I have a problem when creating a db dump from a php script in a html page.
This used to work in previous PostgreSQL versions, but now (v, 9.1.5)
it fails, and i have no idea why.
It is not a matter of write-access, since the directory has mode 777,
and in the same php-file i successfully create a file there.
Here's a minimal version which shows the behavior:
<html>
<head></head>
<body>
<?php
putenv('PG_USER=magnus');
putenv('PG_PASSWORD=mypass');
putenv('PG_DB=magnus2');
putenv('PG_HOST=localhost');
putenv('PGPASSFILE=/home/jody/.pgpass');
$sPath="/home/jody/progs/magnus2/dumps/dumpidump.sql";
$sDBName="magnus2";
$sQuery1="/usr/bin/pg_dump -w -U magnus -c -f $sPath $sDBName";
exec($sQuery1, $output, $iRet);
print("Q:" . $sQuery1 . "<br/>");
print("ret:" . $iRet . "<br/>");
foreach($output as $ss) {
print("out:" . $ss . "<br/>");
}
print("<hr/>\n");
$sQuery2="echo gnagna > " . $sPath . ".test";
exec($sQuery2, $output, $iRet);
print("Q:" . $sQuery2 . "<br/>");
print("ret:" . $iRet . "<br/>");
foreach($output as $ss) {
print("out:" . $ss . "<br/>");
}
?>
The call to pg_dump fails with a return code of 1, and $output is empty.
The second call succeeds with return code 0, and a file is indeed written.
When i replace $sQuery1 by "/usr/bin/pg_dump --version" the cal
succeeds with return code 0,
and $output contains the string "pg_dump (PostgreSQL) 9.1.5"
When i copy-paste the command contained in $sQuery to the command line,
it succeeds.
In my home directory /home/jody i have .pgpass file, with the correct
username and password.
Is there a way to specify a password on the command line?
Can somebody give me a hint how i can get this to work?
Thank You
Jody
--
Sent via pgsql-novice mailing list (pgsql-***@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-novice
Sent via pgsql-novice mailing list (pgsql-***@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-novice