Using psql in Automation Scripts (Non Interactive Usage of psql)
When using command-line tools in the scripts, interactive tools enjoy breaking the automation and asking for some information. Most of the interactive commands have non-interactive modes you can use. I recently discovered how to use default PostgreSQL client in such a way.