TransWikia.com

Could not find a "psql" to execute

Database Administrators Asked by apt605 on October 28, 2021

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?

One Answer

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 ...');

Answered by Evan Carroll on October 28, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP