1

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?

NO WAR WITH RUSSIA
  • 54,954
  • 34
  • 200
  • 411
apt605
  • 73
  • 1
  • 1
  • 4

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 ...');
NO WAR WITH RUSSIA
  • 54,954
  • 34
  • 200
  • 411
  • @apt605 btw, while this answers your question you should not be doing this. You should be using the API to run SQL. – NO WAR WITH RUSSIA Jul 20 '20 at 16:55
  • True Evan -- and we do use the API from PHP for other operations. But this is for a mass insert using the psql /copy command. I do not think there is any API option that can do a bulk insert of records at the same speed. – apt605 Aug 09 '20 at 17:47
  • @apt605 Sure there is. https://www.php.net/manual/en/pdo.pgsqlcopyfromfile.php – NO WAR WITH RUSSIA Aug 10 '20 at 14:03
0

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
  • 121
  • 4