I personally like Francisco Olarte's approach. Hashbang's don't support arguments well ( http://stackoverflow.com/questions/4303128/how-to-use-multiple-arguments-with-a-shebang-i-e) and being able to put JUST psql as the command to execute the script doesn't scale across environments. Previously I've just used a quick wrapper:
https://gist.github.com/frankpinto/3427cf769a72ef25ffac It can be modified to accept arguments for the script name, run a sql script by the same name, have a default environment, etc. Frank On Fri, Jul 18, 2014 at 10:43 AM, Martin Gudmundsson < martingudmunds...@gmail.com> wrote: > +1 > > Skickat från min iPhone > > > 18 jul 2014 kl. 17:58 skrev Adrian Klaver <adrian.kla...@aklaver.com>: > > > >> On 07/18/2014 08:52 AM, Karsten Hilbert wrote: > >> On Fri, Jul 18, 2014 at 08:32:53AM -0700, Adrian Klaver wrote: > > > >> > >> I think the OP is talking about executable scripts so both of > >> > >> $> psql -f the-file.sql > >> > >> and > >> > >> $> ./the-file.sql > >> > >> (where the-file.sql starts with "#!/usr/bin/env psql") > >> > >> would work given that the-file.sql has got execute permission. > > > > Yea, it finally dawned on me what was being asked, so ignore my previous > post. > > > >> > >> Karsten > > > > > > -- > > Adrian Klaver > > adrian.kla...@aklaver.com > > > > > > -- > > Sent via pgsql-general mailing list (pgsql-general@postgresql.org) > > To make changes to your subscription: > > http://www.postgresql.org/mailpref/pgsql-general > > > -- > Sent via pgsql-general mailing list (pgsql-general@postgresql.org) > To make changes to your subscription: > http://www.postgresql.org/mailpref/pgsql-general >