From: | Joseph Shraibman <jks(at)selectacast(dot)net> |
---|---|
To: | Alvaro Herrera <alvherre(at)atentus(dot)com> |
Cc: | David Link <dlink(at)soundscan(dot)com>, PgSQL-General <pgsql-general(at)postgresql(dot)org>, pgsql-docs(at)postgresql(dot)org |
Subject: | Re: sql scripts |
Date: | 2002-01-23 03:12:59 |
Message-ID: | 3C4E2A3B.10600@selectacast.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
When bash interprets the magic line starting with #! it appends the filename to the end of
the command, it doesn't pipe the contents of the file to stdin. So when I was trying to
write the shells script first I tried something like
#!/usr/local/bin/psql -U someuser -d dbname -f
but psql couldn't handle the magic line itself, and you can't have pipes in the magic
line, so I finally settled on using tail on the script itself (inspired by the jdk
installers from sun).
Alvaro Herrera wrote:
> El jue, 20-12-2001 a las 16:48, David Link escribió:
>
>>Joseph Shraibman wrote:
>>
>>>FYI anyone who wants to have a psql shell script:
>>>
>>>#!/bin/bash
>>>tail +4 $0 | /usr/local/pgsql/bin/psql -U postgres -d playpen
>>>exit
>>>
>>>select version();
>>>
>>Very cool. And very clever. Thanks.
>>
>
> It should be possible to do things like
>
> #!/usr/local/bin/psql -U someuser -d dbname
> select version();
>
>
> But the current psql implementation doesn't allow that for various
> reasons. I don't know if it can be "fixed"...
>
>
--
Joseph Shraibman
jks(at)selectacast(dot)net
Increase signal to noise ratio. http://xis.xtenit.com
From | Date | Subject | |
---|---|---|---|
Next Message | Sean Chittenden | 2002-01-23 05:05:03 | Re: Password type ? |
Previous Message | Alvaro Herrera | 2002-01-23 03:00:15 | Re: sql scripts |