Write the psql script to a tmp file before executing.