2

I have a bash script that run on a Linux (AWS Centos) server. There's an odd, but annoying warning message that pops up in the stdout whenever the script executes psql: could not find a "psql" to execute.

What is odd is that that the Postgresql command line psql runs just fine! Yet it still generates this error message.

For further context, the bash script is executed from a shell_exec in a php page (fastcgi/nginx). If you run the bash script from the command line, you don't see the warning. But again, even with the warning, psql does actually run properly.

Does anyone know why this warning appears, and how to eliminate it?

Evan Carroll
  • 65,432
  • 50
  • 254
  • 507
apt605
  • 83
  • 1
  • 1
  • 5

2 Answers2

2

For further context, the bash script is executed from a shell_exec in a php page (fastcgi/nginx).

Try hard setting the path to the psql script so you don't rely on the environmental PATH and PHP setting that when it calls the shell,

Rather than,

$output = shell_exec('psql ...');

Try (or wherever command -v psql shows it's located)

$output = shell_exec('/usr/bin/psql ...');
Evan Carroll
  • 65,432
  • 50
  • 254
  • 507
1

For this error message on Windows, see this bug report: https://www.postgresql.org/message-id/E1VPJrB-00071y-RR%40wrigleys.postgresql.org

The problem seems to be caused if the environment PATH element for PostgreSQL contains double quotes. Try removing them.

rghome
  • 143
  • 1
  • 8