psql
requires password to be entered which you can supply by creating a .pgpass
file.
or by setting the PGPASSWORD
environment variable (Not recommended as per docs)
Use of this environment variable is not recommended for security
reasons, as some operating systems allow non-root users to see process
environment variables via ps; instead consider using a password file
But for a quick check you can try adding
putenv('PGPASSWORD=password');
getenv('PGPASSWORD');
in your php code before the command.
From PHP Docs
output
If the output argument is present, then the specified array will be
filled with every line of output from the command. Trailing
whitespace, such as \n, is not included in this array. Note that if
the array already contains some elements, exec() will append to the
end of the array. If you do not want the function to append elements,
call unset() on the array before passing it to exec().
return_var
If the return_var argument is present along with the output
argument, then the return status of the executed command will be
written to this variable.
check the $out
and $ret
variables for the output and status of the executed command.
CHECK DATA
. Try using$command = 'shp2pgsql -s 2100 -d "D:\CHECK DATA-group\2016\Ayomi\JULY\12FCP151Sup88Sh99\121800151s00088s0099\CM121800151s00088s0099Poly.shp" | psql -h localhost -p 5432 -d ssh -U postgres';
If password is not the issue, this should be it.